Archive for the ‘Programming’ Category

My job as a data analyst requires me to work with a lot of CSV files.  Well, I came upon one that I couldn’t import into SQL using the SQL Import and Export Wizard nor open and manipulate using Excel.  I knew that python was good for manipulating data but I didn’t have any experience with the language.


The internet being the awesome thing it is, I was able to kit-bash this script together using a number of sources (mostly stackexchange):



import csv

f = open(‘input.csv’)
output = open(‘output.csv’, ‘w’)

csv_f = csv.reader(f)
csv_o = csv.writer((output), lineterminator=’\n’)

for row in csv_f:
csv_o.writerow([row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14]])




Now I’m sure there is a sexier way to write a bunch of sequential columns to a new CSV. 🙂 But I was running out of time. Maybe something I look at for the future.


Read Full Post »