The error message:
File "./reading_and_creating_outage_report.py", line 6
with open('major_outages_csv.csv',mode='w') as csv_file:
^
SyntaxError: invalid syntax
I'm stumped. Every example I've seen on Stack Overflow and elsewhere uses this syntax to open a csv file residing in the same directroy as the script. I have found other methods, but I don't like not knowing what is wrong with the way I'm writing this considering it seems to be the same all other samples.
referenced material:
https://realpython.com/python-csv/
https://docs.python.org/2/library/csv.html
script in question:
import csv
with open('major_outages_csv.csv',mode='w') as csv_file:
csv_reader = csv.reader(csv_file,delimiter=',')
line_count = 0
for row in csv_reader:
if line_count == 0:
print('column headers are {", ".join(row)}')
line_count += 1
else:
print('\t{row[0]} is the number of customers out and {row[1]} is the feeder.')
line_count += 1
print ('processed {line_count} lines.')
withstatement