directory

'unexpected indent' in python

'unexpected indent' in python Question: I am making a program in python where I read a filepath, put different pieces of that path in variables, change the path and make a new dir with that path. Everything almost seems to work. But at the end when I try to create the new dirs I am …

Total answers: 2

How to merge folders in every subdirectory using python code?

How to merge folders in every subdirectory using python code? Question: my directory now.[1] I want to combine every Sub in every Folder so it should look something like this [2] [1]: https://i.stack.imgur.com/xz7FJ.png [2]: https://i.stack.imgur.com/scK48.png Asked By: mayuresh || Source Answers: You can iterate through all the files/dirs in a directory using os.walk(). We are …

Total answers: 1

How to import folders in python?

How to import folders in python? Question: I have 3 folders of excel data and was asked to create a Machine Learning model using that data. But the problem is that the data does not have headers. How to import all those folders of data in Python. Asked By: Sounak Sarkar || Source Answers: Python …

Total answers: 1

"SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated UXXXXXXXX escape" . (File management bug)

"SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated UXXXXXXXX escape" . (File management bug) Question: So I’m making a program in Python that goes through all of your files in the download folder but when I run it, it says (SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: …

Total answers: 3

mp3 file name replace

mp3 file name replace Question: So my concern on a logic of a program. I have a Music folder with many mp3 files with underscores in names (MC_-_Best_track.mp3). So I want to scan this folder and replace all underscores with whitespaces. I want to write it myself first but I need a kickstart for that) …

Total answers: 1

How to find directory of something you've downloaded within python script and move it?

How to find directory of something you've downloaded within python script and move it? Question: from genericpath import isdir from pytube import * import os #checks if directory exists, if not creates it if os.path.isdir(‘C:/Users/aidan/Downloads/ytDownloader’): pass else: os.mkdir(‘C:/Users/aidan/Downloads/ytDownloader’) playlist_url = Playlist(‘https://www.youtube.com/playlist?list=PLZYPi8njr7oJLOThbld0Md2x03P2e6qWR’) for url in playlist_url.videos: audio = url.streams.get_audio_only().download() #Here I want to move audio into …

Total answers: 1

Open multiple files with the same extension in a folder

Open multiple files with the same extension in a folder Question: I want to open all files with the same extension (.dat) in the same directory. This is my current code: path = Path(".") # current directory extension = ".dat" file_with_extension = next(path.glob(f"*{extension}")) if file_with_extension: with open(file_with_extension, encoding=’utf-8′) as infile, open(‘462888.dat’, ‘w’, encoding=’utf-8′) as outfile: …

Total answers: 1