Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

PythonValueErrorI0Operation

When I modified the route where the write out files should go. I set up two input and output folders, and each of them had child .csv files in years order. The error appears when I deleted and skipped the years' directory. I guess it's because the files closed before to finish the operation. Can I borrow your wise mind to take a look where goes wrong? Perhaps, how to fix it?

Traceback (most recent call last):
File "count_words_june15.py", line 310, in <module>
writer.writerow([key, value])
ValueError: I/O operation on closed file.

The code itself:

with open(outdir+'advocacy_word_counts.csv', 'w') as csv_file:
    write = csv.writer(csv_file)
    for key, value in evaluation_dic.items():

line 310: writer.writerow([key, value])

with open(outdir+'grassroots_word_counts.csv', 'w') as csv_file:
    write = csv.writer (csv_file)
    for key, value in evaluation_dic.items():
        writer.writerow([key, value])

with open(outdir+'rights_word_counts.csv','w') as csv_file:
    write = csv.writer(csv_file)
    for key, value in evaluation_dic.items():
        writer.writerow([key,value])

Comments