Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant read csv files using pandas in Visual Code

Python : 3.5

IDE : Visual code

Platform : win 10 64 bit

First i created a virtual env _kerasVenv and then activated the env and then installed pandas using pip.

This is my directory structure:

enter image description here

I added a python script in Exercise files folder where I am trying to read .csv file using pandas

test= pd.read_csv('test.csv', encoding='utf-8')

.csv file and python script are in the same folder so wrong path is not the issue.But i am getting below error:

Unable to open 'parsers.pyx': Unable to read file (Error: File not found (c:\users\anubhav.jhalani\downloads\ex_files_building_deep_learning_apps\pandas\_libs\parsers.pyx)).

Can someone explain why python is looking for pandas in c:\users\anubhav.jhalani\downloads\ex_files_building_deep_learning_apps folder and why parsers.pyx file does not exist in original pandas folder which are in _kerasVenv folder? How can i get rid of this error?

Update: I found out while hovering on import pandas as pd statement that it is looking for pandas module in c:\users\anubhav.jhalani\downloads\ex_files_building_deep_learning_apps . Why it is happening?

like image 615
Anudocs Avatar asked Nov 06 '22 13:11

Anudocs


1 Answers

I think it is easier to always give the total file path.

Instead of:

test= pd.read_csv('test.csv', encoding='utf-8')

try to use:

test = pd.read_csv('C:/users/anubhav.jhalani/downloads/ex_files_building_deep_learning_apps/test.csv', endcoding='utf-8')

this should help, you can also have a look here, what syntax you need to write it: Windows path in Python

You can also get the full path in your windows explorer, if you are unsure where it is saved.

like image 164
PV8 Avatar answered Nov 13 '22 03:11

PV8