Skip to main content

All Questions

Tagged with
0 votes
1 answer
57 views

How can I combine multiple CSV files into one Excel worksheet using Python?

I am trying to combine multiple CSV files into an Excel worksheet so I can analyse my data. So far I have been able to create the worksheet with the names of the CSV files as the tabs, but in the ...
user3482176's user avatar
1 vote
2 answers
367 views

Using glob to find all csv files in folder and subfolder but return list is empty

So my ultimate goal is to add the data from multiple .csv files to a dataframe in Jupyter notebook. I have been trying each piece first before I add them together but can't get past just getting the ...
Liraell's user avatar
  • 75
0 votes
1 answer
118 views

Read in csv files in a folder and output to one single csv

I have a folder with many csv files. I want to read them in and depending on certain criteria output the records to specific output files. So in my case I have 3 different output files. So I have many ...
PSt's user avatar
  • 103
0 votes
1 answer
293 views

Using chdir() to read all csv files in a directory [duplicate]

Here is an example of my directory: Auto ├── Test │ └── Test.csv ├── Test2 │ └── Test2.csv └── new.csv I am trying to read all the csv files in the directory. Here is my code: import glob, os os....
GooseCake's user avatar
0 votes
1 answer
42 views

How to load only the most recent file from a directory where the filenames startswith the date?

I have files in one directory/folder named: 2022-07-31_DATA_GVAX_ARPA_COMBINED.csv 2022-08-31_DATA_GVAX_ARPA_COMBINED.csv 2022-09-30_DATA_GVAX_ARPA_COMBINED.csv The folder will be updated with each ...
Mazil_tov998's user avatar
1 vote
1 answer
52 views

Concatenate a .xls file list into .csv

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)...
Mathéo Pérez's user avatar
0 votes
2 answers
2k views

How to load only the most recent file from a directory where the filenames endswith the date?

I have files in one directory/folder named: sacoronavirus_total_number_vaccinated_type_2022-04-30.csv sacoronavirus_total_number_vaccinated_type_2022-05-31.csv ...
Mazil_tov998's user avatar
1 vote
1 answer
248 views

Export Glob list to CSV

I have a folder named "Photos" that contains several images. I am using Glob to list all these images along with their full directory paths. I can print the list and see the full list of ...
Sid James's user avatar
2 votes
1 answer
225 views

Pandas Read CSV Error When Reading Multiple Files

I have multiple csv files, named as 2C-BEB-29-2009-01-18.csv,2C-BEB-29-2010-02-18.csv,2C-BEB-29-2010-03-28.csv, 2C-ISI-12-2010-01-01.csv, and so on. 2C- Part is default in all csv files. BEB means ...
dspractician's user avatar
0 votes
1 answer
402 views

Assign the filename to the imported array in pandas [duplicate]

I have folder which includes many csv files namely a_1, a_2, b_1, b_2, b_1, b_2.... I want to import each csv file as their names. For example a_1 = pd.read_csv("a_1.csv") a_2 = pd.read_csv(&...
helloworld's user avatar
0 votes
1 answer
225 views

python grouping filename and read csv by group and export csv by key

My request is to group filename with similar character, and read and merge all csv files by group, then export csv by key. Here's my code: import glob import pandas as pd path = r'C:\Users\*.csv' ...
Kelvin Lo's user avatar
  • 189
1 vote
2 answers
617 views

Python: How to read globbed CSV files in batches, and store in a DataFrame

I have a large number of .csv files in a folder. All .csv files have the same column names. The below code merges all the .csv files. But I have to merge the top 10 .csv files in one DataFrame after ...
Murari Kumar's user avatar
1 vote
2 answers
830 views

How to replace the header of all CSV files in a directory?

I have a folder of CSV files, and I need to simple replace the current header (first row), of the csv, with a different header. As an example, ever CSV has: A, B, C, D, E as the first first row ...
Rob's user avatar
  • 9
1 vote
2 answers
2k views

How to read csv files with different amounts of columns using Python

import glob files = glob.glob("Data/*.csv") df = pd.concat((pd.read_csv(f) for f in files)) print(df) I get an error that says: "ParserError: Error tokenizing data. C error: Expected ...
Sangeetha's user avatar
1 vote
1 answer
76 views

Import 10 csv files and export as 10 worksheets of 1 xlsx

I have 10 csv files and want to save all the files as 10 worksheets of 1 xlsx file. data1.csv,data2.csv,.......,data10.csv. Attempt import glob import numpy as np import pandas as pd all_datasets = ...
nasa313's user avatar
  • 300

15 30 50 per page
1
2 3 4 5
8