Reputation: 3
I'm a newbie to Python. I downloaded a csv file to use. I use the Anaconda package in Python 2.7 on Windows 8.1. I can open and read the file in Spyder perfectly, but when I try to open it in the iPython shell, i get the following error message:
[Errno 2] No such file or directory: 'C:/Users/User/Desktop/Python stuff/Data.csv
My code -
DSI_data = open('C:/Users/User/Desktop/Python stuff/Data.csv')
DSI_reader = (pd.read_csv(DSI_data), ',')
print DSI_reader
Output :
IOError Traceback (most recent call last)
<ipython-input-2-14a014f3c776> in <module>()
1
----> 2 DSI_data = open(''C:/Users/User/Desktop/Python stuff/Data.csv')
3
4 DSI_reader = (pd.read_csv(DSI_data), ',')
5
IOError: [Errno 2] No such file or directory: 'C:/Users/User/Desktop/Python stuff/Data.csv'
I would like to open this file in Spyder and not being found by iPython. Also, I need to know how to open this iniPython
Upvotes: 0
Views: 6452
Reputation: 1
import pandas as pd
df = pd.read_csv('qwa.csv', encoding='cp1252')
print(df.head())
Upvotes: 0
Reputation: 4581
I am not aware of working with python in windows but Here I am giving the solution to the problem opening the csv file in ipython notebook.
Before using this code please check the path of the csv file.
Loading csv file in ipython notebook
import pandas as pd
DSI_data_path = "C:/Users/User/Desktop/Python stuff/Data.csv"
DSI_data = pd.read_csv(DSI_data_path)
print DSI_data
Upvotes: 1
Reputation: 231540
The issue is one of finding and properly naming the file. I would suggest using
%pwd
to find out what the current directory is.
%ls
to see what is in that directory
and
%cd ...
to change to the right subdirectory.
Also use the tab complete.
f = open('Da<tab>
will give you list of files that start with Da
, assuming you are in the right directory.
Upvotes: 3