I'm making a file compiler that takes data from csv files and after every 8 files read concatenates the data into a separate csv file. The program is taking quite long to be able to do these functions. is there a more optimized way to go about this?
I'm currently reading the csv file into a pandas data frame then appending said data frames into a list to compile them for pd.concat() after.
edit:
The inputs used in the pd.read_csv call is the root's directory and the files name that's being read since im using os.walk to jump from folder to folder. The content in each of the folders is an inconsistent amount of csv files storing data for a model's MSE RMSE and MAE. the reason why im using a data frame is because im trying to use the data in each of the csv files for further data analysis(reason why it concatenates every 8 files is because each model has 8 outputs). All csv files have one row for a header and are 6 columns by 5 rows.
code snippet:
data = []
data_value = pd.read_csv(os.path.join(root, file), sep='\t') #Reading data into df
data.append(data_value) # appending df to a list
pd.concat(data) #concatenating all data in list into a data frame