Saturday, October 27, 2012

Add columns of data to an existing CSV - a case for Bash over Python

I do a lot of scripting in Python, I love it, but sometimes things are just more easy in Bash. Take for instance appending new columns of data into a CSV file. To go about this in Python you would have to do something like the following: Stackoverflow Example. Back yet? Ok, and you would still have to add some logic to open the other file and read through its lines, etc...BUT in Bash, this command is so, so simple:

#paste is the utility and "-d ," specifies the delimiter type
paste -d , file_1.csv file_2.csv > combined_file.csv


No comments:

Post a Comment