glob

Importing multiple .cnv files, extract filename, and attach as a column

Importing multiple .cnv files, extract filename, and attach as a column Question: I have multiple .cnv files that I can import and concatenate with the following code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import glob # Get CSV files list from a folder path =’/Users/mariacristinaalvarez/Documents/High3/’ csv_files = glob.glob(path + …

Total answers: 2

How to delete files with specific patterns in python?

How to delete files with specific patterns in python? Question: I have a bunch of files in the directory web, I need to match the pattern and delete the appropriate files.The files are in the following order 1520_22.txt, 1530_22.txt, 1540_22.txt, new_pwd_v1_asia_1530_22.json, new_pwd_v1_eur_1540_22.json, new_pwd_v1_aus_1520_22.json Each json file has a corresponding text file identified by the number …

Total answers: 1

How to rename images with specific pattern?

How to rename images with specific pattern? Question: I have this image folder as shown below that has repated charchter name A I want only keep one letter A with rest of numbers + ext the input : input_folder –| |— imgs — |– A_0.jpg |– A_A_A_1.jpg |– A_A_2.jpg |– A_A_A_A_3.jpg |– A_4.jpg ……… I …

Total answers: 1

How to have an ordered list of files with digits?

How to have an ordered list of files with digits? Question: I have a folder of files and want to read the files one by one because it is frames of a video. However, when I am trying to have an ordered list of files, it is ordered as follows: data_dir = ‘./data/’ filenames =listdir(data_dir) …

Total answers: 2

Concatenating CSVs into dataframe with filename column

Concatenating CSVs into dataframe with filename column Question: I am trying to concat multiple CSVs that live in subfolders of my parent directory into a data frame, while also adding a new filename column. /ParentDirectory │ │ ├───SubFolder 1 │ test1.csv │ ├───SubFolder 2 │ test2.csv │ ├───SubFolder 3 │ test3.csv │ test4.csv │ ├───SubFolder …

Total answers: 2

how to read specific JSON files using python glob

how to read specific JSON files using python glob Question: i have a set of JSON files in a folder. Sample files: -2022_06_13_07_14_f71cd512135bdab9.json -2022_06_13_07_1421_f71cd512135bdab9.json -2022_06_13_07_12314_f71cd512135bdab9.json -2022_06_14_132_14_f71cd512135bdab9.json -2022_06_14_74647_14_f71cd512135bdab9.json Instead of reading all files at once, I need to read them day-wise. ex:2022_06_13_07_14_f71cd512135bdab9.json corresponding to 2022_06_13. like wise I need to read all the JSON files and …

Total answers: 1

Scanning subdirectories for files that match certain filenames

Scanning subdirectories for files that match certain filenames Question: I want to scan a directory and all its subdirectories for certain file names (i.e. all files having an .log extension, as well as all files whose names are example1.txt or example2.txt), so I can process them further. I succeded in fetching all files ending with …

Total answers: 1

Concatenate a .xls file list into .csv

Concatenate a .xls file list into .csv Question: I’m trying to concatenate a .xls file list into .csv: import glob import pandas as pd file_xls = glob.glob(location + "*.xls") print(file_xls) read_file = pd.read_excel(location + file_xls) but I have an error about the concatenation of the list: TypeError: can only concatenate str (not "list") to str …

Total answers: 2

Collecting Sheet Names from a Folder of Excel Workbooks

Collecting Sheet Names from a Folder of Excel Workbooks Question: I have a folder of numerous .xslx files on my desktop and I am trying to iterate through them one by one to collect the respective sheet names automatically from each workbook. import openpyxl import glob # specifying the path to csv files path = …

Total answers: 2