The Dataiku Frontrunner Awards have launched to recognize your achievements! SUBMIT YOUR ENTRY

Access Files on computer through Jupyter Notebook

WayneKhan
Level 2
Access Files on computer through Jupyter Notebook

I apologize if this has been asked before. I did a search and couldn't find anything.  

For example when I use a jupyter notebook through Ananconda Navigator I can read a csv or excel file on my computer. pd.read_csv('./Documents/folder/file.csv')

How do I do that when I use a jpuyter notebook through dss?

0 Kudos
4 Replies
CoreyS
Community Manager
Community Manager

Hi @WayneKhan while you wait me a more detailed response, and just incase you haven't accessed it already, I wanted to share with you Using Jupyter Notebooks in DSS from our Knowledge Base. I hope this helps!

Looking for more resources to help you use DSS effectively and upskill your knowledge? Check out these great resources: Dataiku Academy | Documentation | Knowledge Base

A reply answered your question? Mark as ‘Accepted Solution’ to help others like you!
0 Kudos
Mark_Treveil
Dataiker Alumni

Use a Managed Folder to store your file. DSS is not a  desktop notebook system and designed to run on servers and on clouds.

folder = dataiku.Folder("myFolder")
with folder.get_download_stream("/accidents_2010.csv") as stream:
     df = pd.read_csv(stream)

 

This works OK for me with a clean CSV file.

VitaliyD
Dataiker
Dataiker

Hi @WayneKhan ,

As Mark_Treveil mentioned, the proper way to handle any file in DSS is to add it to a Managed folder first and then utilize Dataiku API to open and process it in any way required. In some rare cases, you may still want to read files from system folders, the example below will give you an idea of how to do that:

import dataiku
from dataiku import pandasutils as pdu
import pandas as pd
import os

#in this example file located in dataiku home directory.
home_directory_path = os.path.expanduser("~")#find dataiku user home directory
local_filename = os.path.join(home_directory_path, "us-500.csv")
print(local_filename)
with open(local_filename, "rb") as f:
    df = pd.read_csv(f)
df.head()

Screenshot 2021-05-28 at 18.08.22.png

Hope this helps,

Vitaliy

0 Kudos
WayneKhan
Level 2
Author

Thanks everyone!

A banner prompting to get Dataiku DSS
Public