Read CSV from another folder in Jupiter Notebook (python) - python

I have my CSV files in a Data Folder in Jupyter Notebook, then I have a few other notebooks that I want to rely on the CSV files in the Data Folder. How do I read in the CSV files From the Data Folder into the notebooks that I want the analysis to occur in? I'm using a Mac and doing this in Python.

You need to specify the path to the csv file you want to put in pd.read_csv. For example, if your jupyter notebook is located on your Desktop, and the csv file (lets call it "my_project_1") is somewhere else, say in a folder called Projects, and that folder is in your Documents folder, then you specify the path as following:
import pandas as pd
df = pd.read_csv('/Users/your_user_name/Documents/Projects/my_project_1.csv')
Don't forget to change your_user_name to your actual user name.

Related

Save excel file to local storage from Jupyter using python

I am working with Pandas and I have plenty of Excel files which I need to store in my local storage directly from Jupyter Notebook.
For example,
I create an excel file named "test.xlsx".
Now I want to save this excel file into somewhere in my C:/ drive.
Please help me out with the coding part in python.

Voila not to Load Certain .ipynb Files

I am very new to Voila and Jupyter. I understand Jupyter notebook files (i.e. files with extension .ipynb) can be loaded in either Voila server or Jupyter server.
To elaborate, for instance, we have files below in the same folder: -
a.ipynb
b.ipynb
My question is that if it is possible for me only to load "a.ipynb" in Voila? The example is just for purpose of demonstration. We could have a large number of files / folders in the folder.
I have scanned through Voila website but doesn't look like there is any existing feature I can use to support this.
Thank you.

Jupyter Notebook/Pandas not reading excel file after moving ipynb

I'm working on automating some reporting for work which starts off with a pd.read_excel method. It worked fine and I moved on with the rest of my code. When I was done, I had a few ipynb files on my desktop and moved them into a folder called "Python". After doing so, I'm getting a "No such file or directory" error when rerunning the code. The file is in a folder called "Reporting". I can leave them on the desktop for now, but typically have everything organized in folders to avoid clutter. What do I need to do to get my code to continue read in the excel files?
RawData=pd.read_excel("Reporting/LS_Questions.xlsx",skiprows=2)
Try using an absolute path rather than a relative path.
Right now your path assumes that the file is within the same directory as the notebook.
you can either:
use a full path a.i - "C:\User{user_name}\Desktop\LS_Questions.xlsx"
Move the CSV/XL file to the directory of the notebook.

How to Upload a File Using Pandas in Python

I'm having a problem uploading a file ( the file is called "kickstarter1.csv" it is in the image that I attached) using Pandas in python. In the bottom of the picture I attached, it is saying that the file does not exist. I found out a way to view the full path of my file which is located at the bottom of the finder window ( it is in the image I attached). How do I code the full path into my pandas code? I'm using Anaconda Navigator ( I'm not sure if that is relevant).
provide the complete path of your CSV file while reading it through pandas as
name_you_want = pd.read_csv('path/file_name.csv')
or go to the specific folder using cd command on notebook and then read the CSV file.

How to create a watch folder in python to import .csv files automatically

For my project, I want to import a .csv file as soon as it is dropped in a certain folder. I want to make that folder a watch folder so that whenever someone drops a .csv file into that folder, it is automatically imported into my project instead of me running the code to import it every time.
I want to automate this process of data injection as new .csv files will be used every day. Is there is any other way to automate this process? I am a newbie so looking for possible suggestions.

Categories

Resources