Why can't I access a CSV file saved from Jupyter Notebook? - python

I am writing a dataframe to csv, but I am unable to view or access the file from file explorer. Any suggestions on how to access the file directly from file explorer?
I am using pandas functions "to_csv" and "read_csv" in Jupyter Notebook. I am successful in writing and reading from the csv file, which indicates the command is working.
However, the csv file is not present in File Explorer.

Related

Saving Excel files in Python to a OneDrive Directory and then error opening the file do it being used by Python

My Python code properly writes to Excel using the pandas pd.ExcelWriter function. The challenge I am having is that I am saving the file to a OneDrive directory and it won't let me open the file in Excel once the code is executed unless I close Python. Effectively, the Excel file is considered still be used by Python and therefore cannot get synced in OneDrive.
Any suggestions on how to deal with this?

Why is my jupyter notebook .ipynb file NOT updating when I download it as a .py file despite making changes in the .ipynb file?

I have just encountered some very strange behaviour in Jupyter Notebook. I edited an .ipynb file and downloaded it as the .py file equivalent. However, when I look at the .py file, the changes have not been made. It is as if the download as function is referencing an earlier version of the .ipynb file somewhere, but I cannot understand the behaviour.
I have tried renaming the .ipynb file and then downloading it again and it DOES update in the new .py file. Then I change the file name back to the original .ipynb file name and save it again as a .py file BUT it reverts to the original unchanged .py file.
Any ideas or explanation here for what is going on and how to fix please? Thanks!

Python generated file not showing up in working directory

I have a couple of Python scripts that are acting funny on my computer. A couple of colleagues use the same script and don't have any issues. Both scripts take a .csv as an input, make some transformations and then open a new .csv or Excel file.
One of them will open the new file, but it won't show up in the working directory; when you go to save the open file then it says the file already exists in the working directory. It allows you to replace it, but even after this is doesn't show up. A picture of that is below.
Here is the saving script for that:
result.to_csv('TypeMapping_filled_{}.csv'.format(str(datetime.date.today())), index=None, header=True)
os.startfile('TypeMapping_filled_{}.csv'.format(str(datetime.date.today())))
The other one will run the script, but the file won't open or show up in the directory.
Here is the saving script for that:
styled_output.to_excel(f'REFORMATTED_{file_name[:(len(file_name)-4)]}.xlsx', index=None, header=True, engine='openpyxl')
Any thoughts on what might be going on?

How do you import a CSV file in Jupyter Notebook?

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()

Excel file is corrupted

After read and write an excel file using python modules xlrd and xlwt, my excel file is corrupted. I faced following prompt while opening using excel 2016. But, the file is opening perfectly in google sheets...
The error excel 2016 throwing is
"Can't open file beacuse the file format or file extension is not valid"
As I mentioned in my above comment, the xlwt package (https://pypi.org/project/xlwt/) is only capable of writing to xls format.
Either change the extension of your file and try it, or change your code to save it as xls format.
I can't see your code but imagine it would look something like this:
wb.save('example.xlsx')
when it should be
wb.save('example.xls')

Categories