Skip to content

Instantly share code, notes, and snippets.

@hheimbuerger
Created June 5, 2011 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hheimbuerger/1008881 to your computer and use it in GitHub Desktop.
Save hheimbuerger/1008881 to your computer and use it in GitHub Desktop.
import csv
with open('input.csv', 'rb') as input, open('output.csv', 'wb') as output:
reader = csv.reader(input, delimiter=';')
writer = csv.writer(output, delimiter=';')
for input_row in reader:
firstname, name, accno, bsc, amount = input_row
output_row = [name, '%s %s' % (firstname, name), accno, bsc, amount]
writer.writerow(output_row)
# For Jython 2.5, the context manager usage ('with') has to be replaced with a classic try..finally.
# For Python 3.x, the files have to be opened in text mode ('r', 'w') instead of binary mode ('rb', 'wb').
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment