Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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]
# 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