Why doesn’t this work?
import csv
with open(‘LabInstrumentList.csv’, ‘r’) as instrumentCsv:
instrumentList = csv.DictReader(instrumentCsv)
for row in instrumentList:
print(row)
I am getting the following error:
ValueError: I/O operation on closed file.
I don’t know why it doesn’t show my indents. but the 3rd line of code is within the “with” and the “for” is outside the “with”. And the “print” is within the “for”.
I moved this topic to the Python subforum.
To display your code with indents, enclose it in triple backticks or use the </>
code button in the menu.
zaklina
December 15, 2023, 3:23pm
4
system
Closed
June 15, 2024, 3:24am
5
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.