Joshua Martinez
Joshua Martinez

Reputation: 104

.csv is empty after reading it with pd.read_csv()

After running

df = pd.read_csv('my_file.csv'),

my original .csv file goes blank. Is there a way to read the .csv data without emptying the original file?

Upvotes: 1

Views: 163

Answers (1)

Amir Shabani
Amir Shabani

Reputation: 4197

pd.read_csv() does not modify the file!

Here, the file before using pd.read_csv():

enter image description here

Using it:

enter image description here

And now if we check it again, the file hasn't changed (as expected):

enter image description here

So the problem isn't with pd.read_csv(). I would assume that you have other code that's messing things up. Take a look and tell us, so we can help you better.

Upvotes: 1

Related Questions