Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cannot find file
#1
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
Reply
#2
full traceback?
Reply
#3
(Jan-11-2017, 07:14 AM)buran Wrote: full traceback?
Solved. Stupid mistake I made. I have to save the file as .txt explicitly.
Reply
#4
Stupid mistakes are the best ones for learning what not to do.
Nobody fails if they never try!
Reply
#5
(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:
Reply
#6
Curious - did you know you were answering a post from January?
Reply
#7
(Apr-20-2017, 03:06 AM)Larz60+ Wrote: Curious - did you know you were answering a post from January?

bahaha i did not
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  FileNotFoundError: [WinError 2] The system cannot find the file specified NewBiee 2 1,496 Jul-31-2023, 11:42 AM
Last Post: deanhystad
  Cannot find py credentials file standenman 5 1,572 Feb-25-2023, 08:30 PM
Last Post: Jeff900
  selenium can't find a file in my desk ? SouAmego22 0 702 Feb-14-2023, 03:21 PM
Last Post: SouAmego22
  Find (each) element from a list in a file tester_V 3 1,157 Nov-15-2022, 08:40 PM
Last Post: tester_V
  what will be the best way to find data in txt file? korenron 2 1,128 Jul-25-2022, 10:03 AM
Last Post: korenron
  find some word in text list file and a bit change to them RolanRoll 3 1,482 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  Find and delete above a certain line in text file cubangt 12 3,354 Mar-18-2022, 07:49 PM
Last Post: snippsat
Question Help to find the largest int number in a file directory SalzmannNicholas 1 1,588 Jan-13-2022, 05:22 PM
Last Post: ndc85430
Thumbs Up [SOLVED] Find last occurence of pattern in text file? Winfried 4 4,309 Aug-13-2021, 08:21 PM
Last Post: Winfried
Music XML File - cannot find the tag ateestructural 1 2,099 Apr-06-2021, 08:26 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020