got a good file.zip this time.
I was able to get this to run (with errors) by reducing the chunk size and a few other adjustments.
I have 32GB or memory, and a chunk size of 20,000 blew up.
if you can't get the code below to run (only one file), reduce chunk size until it does.
And don't forget, you're appending the entire file into a temporary list, so if you don't have enough memory, this will either blow up, or be stuck paging memory for a long time.
I was able to get this to run (with errors) by reducing the chunk size and a few other adjustments.
I have 32GB or memory, and a chunk size of 20,000 blew up.
if you can't get the code below to run (only one file), reduce chunk size until it does.
And don't forget, you're appending the entire file into a temporary list, so if you don't have enough memory, this will either blow up, or be stuck paging memory for a long time.
import os import pandas as pd # assure in proper directory os.chdir(os.path.abspath(os.path.dirname(__file__))) # for my test list_raw_files = ['130000054.csv'] # Location of all files # file_folder = 'path_on_your_computer' # # Save the files into a list (when more than 2) # list_raw_files = [f for f in listdir(file_folder) if isfile(join(file_folder, f))] # Load the right/given file for raw_file in list_raw_files: # Check the file if raw_file.startswith('130'): #print (raw_file) temp_list = [] file_folder = './' for chunk in pd.read_csv(file_folder + raw_file, sep = ';', header = None, chunksize = 10000, error_bad_lines = False , low_memory=False): temp_list.append(chunk) data = pd.concat(temp_list, axis = 0) del temp_list data.head(30)partial error list:
Output:b'Skipping line 10: expected 5 fields, saw 6\nSkipping line 11: expected 5 fields, saw 6\nSkipping line 13: expected 5 fields, saw 6\nSkipping line 15: expected 5 fields, saw 6\nSkipping line 17: expected 5 fields, saw 6\nSkipping line 23: expected 5 fields, saw 6\nSkipping line 24: expected 5 fields, saw 6\nSkipping line 25: expected 5 fields, saw 6\nSkipping line 27: expected 5 fields, saw 96\nSkipping line 28: expected 5 fields, saw 96\nSkipping line 29: expected 5 fields, saw 96\nSkipping line 30: expected 5 fields, saw 96\nSkipping line 31: expected 5 fields, saw 96\nSkipping line 32: expected 5 fields, saw 96\nSkipping line 33: expected 5 fields, saw 96\nSkipping line 34: expected 5 fields, saw 6\nSkipping line 35: expected 5 fields, saw 96\nSkipping line 36: expected 5 fields, saw 96\nSkipping line 37: expected 5 fields, saw 6\nSkipping line 38: expected 5 fields, saw 96\nSkipping line 39: expected 5 fields, saw 96\nSkipping line 40: expected 5 fields, saw 96\nSkipping line 41: expected 5 fields, saw 6\nSkipping line 42: expected 5 fields, saw 96\nSkipping line 43: expected 5