Coming soon - Get a detailed view of why an account is flagged as spam!
view details

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.

1
Permission denied when reading multiple csv's from folder but not when only one
Post Body

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?

Author
Account Strength
90%
Account Age
6 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,745
Link Karma
940
Comment Karma
805
Profile updated: 1 month ago
Posts updated: 9 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
4 years ago