-1

I got this error when I tried to open the csv file where I made the changes I wanted to know the reason for this error (FileNotFoundError : [Errno 2] No such file or directory: 'bahal.csv')

import csv
from statistics import mean
with open('bahal.csv') as f:
    reader = csv.reader(f)
    for row in reader:
        name = row[0]
        average = statistics.mean(row[1:])
        javab = name , average
print(javab)
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61

2 Answers2

0

good prectise is to use full file names because with relative it is hard to keep track of where what is

if you run:

user@~$ python file.py

it will see just files in ~(home dir)

if you run:

user@~/workfolder$ python file.py

it will see ~/workfolder files and so on

main thing is what the working dir is

-1

The file bahal. csv should be in the same folder as the pyton file you are working on OR Try including full path.

THE TECHIE HAND
  • 426
  • 1
  • 4
  • 8