I have 67 csv files with over 1gb of data combined. Each CSV contains 20 columns, but I need only 3 of those columns per csv file. I can successfully combine all of them into a single csv file, but this creates a mammoth file that I don't need. Instead, I want only 3 of those columns from all 67 files combined into a single file (of course, with only three columns).
My current error message is the index out of range error, but I don't know how to fix that within this code. Here is the code that I am using:
import glob
import pandas as pd
path = "C:/Correct/Path"
file_list = glob.glob(path + "/*.csv")
csv_list = []
for file in file_list:
csv_list.append(pd.read_csv(file, delim_whitespace=1, usecols=[9], engine='python'))
csv_merged = pd.DataFrame()
for csv_file in csv_list:
csv_merged = csv_merged.append(
csv_file, ignore_index=True)
csv_merged.to_csv('all_counties.csv', index=False)