Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
petit problème python
#1
programme
def extraction_donnees(texte):
    fichier = open(texte)
    contenu = fichier.read()
    fichier.close()

    lignes = contenu.split('\n')
    print (lignes)

extraction_donnees("democraphique.csv")                   
erreur
Error:
Traceback (most recent call last): File "C:\Users\hp\Desktop\Nouveau dossier\democraphique.py.py", line 9, in <module> extraction_donnees("democraphique.csv") File "C:\Users\hp\Desktop\Nouveau dossier\democraphique.py.py", line 2, in extraction_donnees fichier = open(texte) FileNotFoundError: [Errno 2] No such file or directory: 'democraphique.csv'
Reply
#2
The error is explaining that it cannot find a file with the name: 'democraphique.csv' in the directory named: 'C:\Users\hp\Desktop\Nouveau dossier\democraphique.py.py'
if the file does exist, and there are no spelling errors, you may be get an error of this sort if
the source file is located in a directory other than where the program resides (if using virtual environment, for example).
Or if the file is in a different directory than the script source you will get this error.

is 'democraphique.py.py' actually part of the directory name?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problème command paulo 2 1,611 Feb-09-2020, 08:25 AM
Last Post: paulo

Forum Jump:

User Panel Messages

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