+2 votes
in Programming Languages by (15.7k points)

I am running a python code that reads an input file on a Windows machine, but it's giving the following error:

Traceback (most recent call last):
  File "suicide_rate_plot.py", line 20, in <module>
    with open(infile, 'r') as fin:
IOError: [Errno 22] invalid mode ('r') or filename: 'C:\\Users\\tommy\\Data_for_Paper\x803_16\new_data\\ccae2003_16_plot_data_by_state_new.csv'

1 Answer

0 votes
by (27.1k points)

You filepath seems wrong. On the Windows system, you separate folder name by "\\" instead of "/" or "\". You might have "/" or "\" in your filename and hence it added "x803_16" to your filename.

Try the following filename: