This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I was super excited to find a youtube video that showed me how to read all the csv's in a folder into a pandas dataframe. I've followed along with the video and data provided and everything worked.
​
Now when I try and do it on my own folder on my desktop, I get a permissions denied error! It's my own laptop, and I can get the code to work to read a single csv in the exact same folder. I only get an error when trying to read all the files in the folder. No idea why (only about 2 months into learning python)
​
It's my own computer and I'm pretty sure I should have access to everything lol.
Here is the code:
​
import pandas as pd
import os
​
# df = pd.read_csv('./2020-21 Raw Data/October/October 2, 2020 Practice Cropped.csv')
​
files = [file for file in os.listdir('./2020-21 Raw Data')]
​
all_data = pd.DataFrame()
​
for file in files:
df = pd.read_csv('./2020-21 Raw Data/' file)
all_data = pd.concat([all_data, df])
​
​
The commented out line actually works and lets me read any single file, but I'm not understanding why it won't work with multiple. Is there something where python needs permission to my operating system or something?
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnpython...