I have a .csv file with 52 columns and the length varies between 800.000 and 100.0000.000 rows. I need to convert this big file in multiple .csv files that all of them having 52 columns (same always) and 150.000 rows, (the last one doesn't matter the amount of rows, it is what it is left of it always with 150.000 rows or less). Examples of a input.csv of 550.00 rows:
Output:
split_1_of_4.csv(150.000 rows)
split_2_of_4.csv(150.000 rows)
split_3_of_4.csv(150.000 rows)
split_4_of_4.csv(100.000 rows)
CodePudding user response:
I found a tutorial that splits CSV files using Python: https://dzone.com/articles/splitting-csv-files-in-python
CodePudding user response:
If you don't need to program this yourself, I suggest using GoCSV's split command:
Split a CSV into multiple files.
Usage:
gocsv split --max-rows N [--filename-base FILENAME] FILE
You can find pre-built binaries here, GoCSV Releases.
