0

I'm getting a FileNotFound error yet the file exists. I am trying to chunk a large .csv file into smaller chunks to store on my PC and easily work with using excel. However, I can't get past the error. this my code...

import pandas as pd

chunk_size = 50000
batch_no = 1

for chunk in pd.read_csv('action-network_users.csv', chunksize = chunk_size):
   chunk.to_csv('action-network_users' + str(batch_no) + '.csv', index = False)
   batch_no =+1
J_Meloff
  • 13
  • 4
  • is the `csv` file in same directory where your python script is in? – niraj Oct 02 '20 at 00:46
  • 1
    You can also try printing the current directory to see whether it is where you think it's running or not. `import os` `print(os.getcwd())`. When you refer to the files as `'action-network_users.csv'` you're telling your program to find it in the current directory. – user2089810 Oct 02 '20 at 00:54
  • Yes it's in the same directory and also on the desktop – J_Meloff Oct 02 '20 at 01:12
  • More things your can try are: 1) list all the files in the current directory and check if you see your file listed: https://stackoverflow.com/questions/11968976/list-files-only-in-the-current-directory 2) double-check the name of the file is correct, all underscores and hyphens too. 3) try replacing the name of the file with the full path to it, such as `C:/Path/To/My/File/file.csv` or `/home/users/asdf/file.csv` – user2089810 Oct 02 '20 at 01:25
  • I tried to change the name of my file. I only used underscores, changed my code also, and tried to list everything in my directory. I see the file but I still get the same error – J_Meloff Oct 02 '20 at 04:19
  • This is a link to a screenshot of the error. https://www.dropbox.com/h?preview=Screenshot+2020-10-02+06.15.39.png – J_Meloff Oct 02 '20 at 04:21

0 Answers0