Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert csv to ascii
import csv
with open('log_transformed_truncated.csv', 'w') as outfile:
c = csv.writer(outfile)
counter = 0
with open('log_prepared_truncated.csv','rb') as f:
for row in csv.reader(f, delimiter=','):
counter = counter + 1
mod_row = []
if counter != 1:
for cell in row:
mod_row.append(sum(bytearray(cell)))
else:
for cell in row:
mod_row.append(cell)
c.writerow(mod_row)
print "processed {} rows".format(counter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment