[PYTHON HELP]
Hello, I would like some help figuring out how to import data from n number of files within a folder. When I try to extract the actual data I get an error stating that the file/directory does not exist.
import os, csv
path = ("my directory")
files = sorted(os.listdir(path))
def f():
for file in (files):
with open(file, 'r') as csvfile:
data = csvfile.read
print(data)
OUTPUT:
File "<ipython-input-158-1f4c11da5a68>", line 1, in <module>
f()
File "<ipython-input-157-b977510dbfcd>", line 8, in f
with open(file, 'r') as csvfile:
FileNotFoundError: [Errno 2] No such file or directory: '.csv'