operating-system

Python MacOS Loop Files Get File Info

Python MacOS Loop Files Get File Info Question: I am trying to loop through all mp3 files in my directory in MacOS Monterrey and for every iteration get the file’s more info attributes, like Title, Duration, Authors etc. I found a post saying use xattr, but when i create a variable with xattr it doesn’t …

Total answers: 1

python elegant way to create folders and move files

python elegant way to create folders and move files Question: Currently, I have more than 30 .xlsx files in my source folder. All these 30 files are from different regions in APAC which has keywords such as IND, KOR, ASN etc. My objective is to do the below a) create separate folders for each region …

Total answers: 1

Delete CSV file if missing specific column using python

Delete CSV file if missing specific column using python Question: Currently my code looks into CSV files in a folder and replaces strings based on if the file has column ‘PROD_NAME’ in the data. If it doesnt have column ‘PROD_NAME’, I’m trying to delete those files in the folder. I can get my code to …

Total answers: 1

How to concatente a list of csv (including empty ones) using Pandas

How to concatenate a list of csv files (including empty ones) using Pandas Question: I have a list of .csv files stored in a local folder and I’m trying to concatenate them into one single dataframe. Here is the code I’m using : import pandas as pd import os folder = r’C:Users_M92DesktopmyFolder’ df = pd.concat([pd.read_csv(os.path.join(folder, …

Total answers: 2

How to loop through a folder in Python

How to loop through a folder in Python Question: I am a new python user and I am trying to loop through all the items in a set file. Here is my code this far – import os import pandas as pd print(os.getcwd()) for files in os.listdir(r"../Python/Rev Renewables/Inputs/Option Inputs/"): file = pd.read_excel(files,sheet_name=’ContractSpecs’) print(file) When I …

Total answers: 3

problem renaming files with os.rename and my counter

problem renaming files with os.rename and my counter Question: I’m trying to rename a load of files and using a counter which is loaded into the name. When I run the script the files in the folder get renamed to start at 02, and not 01. When i print the counter in the loop it …

Total answers: 2

Why does a recursive Python program not crash my system?

Why does a recursive Python program not crash my system? Question: I’ve written an R.py script which contains the following two lines: import os os.system("python3 R.py") I expected my system to run out of memory after running this script for a few minutes, but it is still surprisingly responsive. Does someone know, what kind of …

Total answers: 1

Reading multiple txt files from multiple folders

Reading multiple txt files from multiple folders Question: I have 20 folders, each containing 50 txt files, I need to read all of them in order to compare the word counts of each folder. I know how to read multiple files in one folder, but it is slow, is there a more efficient way instead …

Total answers: 2

How SharedMemory in python define the size?

How SharedMemory in python define the size? Question: I have some prolem about SharedMemory in python3.8,any help will be good. Question 1. SharedMemory has one parameter SIZE,the doc tell me the unit is byte.I created a instance of 1 byte size,then, let shm.buf=bytearray[1,2,3,4], it can work and no any exception!why? Question 2. why print buffer …

Total answers: 2

how can I make directory?

how can I make directory? Question: The given code is showing me the error; I am making the folder under folder under folder according to different classes and its videos. train is folder contains different class folder, every class folder have certain videos. directory of train is something like this; —train —-class1 —-video11.mp4 —-video12.mp4 … …

Total answers: 3