I'm a beginner programmer and I'm trying to import a CSV file into Jupyter Notebook. I am following the instruction on this article link. However when I change the file used on the link to my file I get this error Error Image. How should I go about addressing this issue?
Carry your .csv file to the same directory with your notebook (If you use windows as OS, it probably will be in C:\Users\your username as default). Then you better call your data file by pandas.read_csv()
Related
I am running Spyder in Linux Ubuntu and am trying to use data saved in a .txt file that is saved in the same directory as the python script I am trying to load it to using numpy's loadtxt function, however every time i try to, an error comes up stating that the file is not found which doesn't make sense as they are both in the same directory.
I am just wondering if anyone knows what this issue could be, other than the file not being in the same directory or the file name being spelt wrong in my code as neither is the case.
Any help would be very much appreciated!
I can't open a CSV file on Jupyter Notebook. Every time I try to open up, I get this...
Any suggestions or advice would be much appreciated!
The issue is with the forward slashes in your path. Change them to double backslashes:
C:/Users/nsap/desktop...
to
C:\\Users\\nsap\\desktop
Please see this stackoverflow link for more info Error while reading a csv file in python using pandas
I'm new to Pandas and I was beginning to run a simple code to work with this CSV file I downloaded from the government portal. Here's my code -
import pandas as pd
df = pd.read_excel(r'C:\Users\ADMIN\Desktop\Abhishek')
print(df.head)
The path is correct and it didn't work without adding the r at the beginning so I used that. However, this code results in these errors and I'm not sure how to handle any of them.
I've opened the file on Excel and I don't think there's any problem with it. What am I doing wrong?
Python doesn't have permission to open the file. Run your interpreter as administrator, or adjust permissions.
Right click your python shell and select "run as administrator".
Dear Stackoverflow members
I've been trying to install and use the xlwings addin for several days now but I am not able to get it running... I really would like to use xlwings, but it is being painfully difficult.
I am using Anaconda.
xwlings is installed and works perfectly (I can read/write from/to an .xlsx file) but what I want to really do is to call python functions from excel and for that I need the addin.
The docs are not super useful here and I've tried to follow this guide (from https://newtonexcelbach.com/2017/07/30/installing-xlwings-0-11-4/):
" Run xlwings addin install from a command prompt. Reopen Excel and check if the xlwings Ribbon appears. If not, copy xlwings.xlam (from your xlwings installation folder under addin\xlwings.xlam manually into the XLSTART folder. You can find the location of this folder under Options > Trust Center > Trust Center Settingsā¦ > Trusted Locations, under the description Excel default location: User StartUp. Restart Excel and you should see the add-in"
When I opened excel I did not see the addin. I put the xlwings .xlam file into the XLSTAR folder... reopened excel and the addin was still not there. Then I put the .xlam file also in this folder : "C:\Users\UserName\AppData\Roaming\Microsoft\AddIns".
The .xlam file is now in both folders, and now I can see the xlwings addin.
then I create a folder with myproject.xlsm and myproject.py files by running "xlwings quickstart myproject" from the anaconda promt. The files are there but then when I try to call any python function/Script from the vba modules I always get this error:
"Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\joanc\myproject\myproject.py", line 1, in <module>
import xlwings as xw
ModuleNotFoundError: No module named 'xlwings'"
for example, I get this error when I try to run the code that is already available when myproject.xlsm is created. The code looks like this:
sub SampleCall()
mymodule=Left(ThisWorkbook.Name, (InStrRev(ThisWorkbook.Name, ".",-1, vbTextCompare)
RunPython("import " & mymodule & ";" & mymodule ".hello_xlwings()")
end sub
I tried to run this code directly from the developer tab and also from a button created in sheet1 and assigning its corresponding macro...
As a side note if I go to the developer tab>tools>references i can see the xlwings checkbox active... so this should not be a problem.
Well, this is all I've done so far... no idea what I am doing wrong and what to do next. I would really like to use this package but if anyone knows a good alternative I am totally open (not only to read/write from/to excel but also to call python scripts/functions directly from excel)
Thank you very much for your help
I use Ipython Notebook for all python scripting and also making notes with markdown cells.
Sometime back I had downloaded my Ipython Notebook as xyz.py file using File>Download Notebook as .py file option.
Now I need to import the same xyz.py file back into Ipython Notebook.
How can I achieve this?
Have tried creating a new Notebook and in a cell ran
%load xyz.py
but it loads the raw contents of the file in a single cell.
And does not render markdown cells and code cells content as it was there in the original Notebook.
As far as I understand the Python .py file export is one direction process as it loses information in the process.
If you wish to repopen the notebooks for edit use the native JSON (ipynb) format.
For now your option is to reconstruct the cells from the source code by hand.