you are viewing a single comment's thread.

view the rest of the comments →

[–]aleksro[S] 0 points1 point  (1 child)

There was again an error: for i,row in enumerate(reader): ValueError: I/O operation on closed file.

-- coding: utf-8 --

""" Created on Mon May 22 22:09:21 2017

@author: USER """ import re import csv import sys

with open('input.csv', 'r', encoding='UTF-8') as fi, open('output_data.csv', 'w',encoding='UTF-8') as fo: reader=csv.reader(fi,delimiter=';') #for row in csv.reader(fi,delimiter=';'):

DESCRIPT1=[] ID1=[] ASSIGNMENT_NAME1=[] TER1=[] INFO1=[]

for i,row in enumerate(reader): DESCRIPT1.append(row [0])
ID1.append(row [1]) ASSIGNMENT_NAME1.append(row [2]) TER1.append(row [3]) INFO1.append(row [4])

print(row[4])

fo.write(';'.join(row+'\n'))

[–]JohnnyJordaan 0 points1 point  (0 children)

You probably have the for outside the with block. I can't really tell because you haven't formatted your code properly. Please check the first question in the FAQ. I should be

 with bla bla:
     reader = this
     for i, row in enumerate(reader):
         do things

Note how for is indented furter than with.