Skip to content

Instantly share code, notes, and snippets.

@aaronr
Created December 18, 2014 01:00
Show Gist options
  • Save aaronr/f04c5a18e1f2cc506cb5 to your computer and use it in GitHub Desktop.
Save aaronr/f04c5a18e1f2cc506cb5 to your computer and use it in GitHub Desktop.
csv writer
import os
import csv
extra = [
'extra_column',
]
csvfile = open(os.path.join(options.output_directory,options.output_name+'.csv'), "wb")
writer = csv.writer(csvfile, delimiter=',')
header = ['id','Longitude','Latitude','path']
# add extra headers if needed
header.extend(extra)
writer.writerow(header)
row = [str(id),str(lon),str(lat),str(path)]
# add extra data if extra headers where used
row.extend(extra_out)
writer.writerow(row)
csvfile.flush()
csvfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment