Python Forum
cannot find file - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: cannot find file (/thread-1535.html)



cannot find file - landlord1984 - Jan-11-2017

I am learning loading files by open().
I am sure I placed my text file in the same folder with my scripts.
But still get error:No such file or directory

I am using Python 3.5 with Eclipse.

Thanks,

L

import matplotlib.pyplot as plt
import csv

x = []
y = []

with open('example.txt','r') as csvfile:
    plots = csv.reader(csvfile, delimiter=',')
Above is my code


RE: cannot find file - buran - Jan-11-2017

full traceback?


RE: cannot find file - landlord1984 - Jan-11-2017

(Jan-11-2017, 07:14 AM)buran Wrote: full traceback?
Solved. Stupid mistake I made. I have to save the file as .txt explicitly.


RE: cannot find file - Larz60+ - Jan-11-2017

Stupid mistakes are the best ones for learning what not to do.
Nobody fails if they never try!


RE: cannot find file - Low_Ki_ - Apr-20-2017

(Jan-11-2017, 07:04 AM)landlord1984 Wrote: I am learning loading files by open().
I am sure I placed my text file in the same folder with my scripts.
But still get error:No such file or directory

I am using Python 3.5 with Eclipse.

Thanks,

L

import matplotlib.pyplot as plt
import csv

x = []
y = []

with open('example.txt','r') as csvfile:
    plots = csv.reader(csvfile, delimiter=',')
Above is my code

Might I add that you do not have to open a file using the 'r' argument. Files are opened automatically in read mode if nothing is specified.

EX:

with open(filename) as f_obj:



RE: cannot find file - Larz60+ - Apr-20-2017

Curious - did you know you were answering a post from January?


RE: cannot find file - Low_Ki_ - Apr-20-2017

(Apr-20-2017, 03:06 AM)Larz60+ Wrote: Curious - did you know you were answering a post from January?

bahaha i did not