I have a csv file with four columns (no header). I would like to sort the file by the first, then second column, and store back to disk.
I can read the file in using pandas or numpy, no problem, but not sure how to sort it, and store.
I have a csv file with four columns (no header). I would like to sort the file by the first, then second column, and store back to disk.
I can read the file in using pandas or numpy, no problem, but not sure how to sort it, and store.
just like you wanted to process:
If we chain all steps together, then we don't even need to create a variable for the DataFrame...
Demo:
(pd.read_csv('/path/to/file.csv', header=None)
.sort_values([0,1])
.to_csv('/path/to/result.csv', index=False, header=None))