You can add automatically generated code to load data from project data assets to a notebook cell. The asset type can be a file or a database connection.
By clicking in an empty code cell in your notebook, clicking the Code snippets icon () from the notebook toolbar,
selecting Read data and an asset from the project, you can:
Insert the data source access credentials. This capability is available for all data assets that are added to a project. With the credentials, you can write your own code to access the asset and load the data into data structures of your choice.
Generate code that is added to the notebook cell. The inserted code serves as a quick start to allow you to easily begin working with a data set or connection. For production systems, you should carefully review the inserted code to determine
if you should write your own code that better meets your needs.
When you run the code cell, the data is accessed and loaded into the data structure you selected.
Notes:
The ability to provide generated code is disabled for some connections if:
The connection credentials are personal credentials
The connection uses a secure gateway link
The connection credentials are stored in vaults
If the file type or database connection that you are using doesn't appear in the following lists, you can select to create generic code. For Python this is a StreamingBody object and for R a textConnection object.
The following tables show you which data source connections (file types and database connections) support the option to generate code. The options for generating code vary depending on the data source, the notebook coding language, and the notebook
runtime compute.
Supported files types
Copy link to section
Table 1. Supported file types
Data source
Notebook coding language
Compute engine type
Available support to load data
CSV files
Python
Anaconda Python distribution
Load data into pandasDataFrame
With Spark
Load data into pandasDataFrame and sparkSessionDataFrame
With Hadoop
Load data into pandasDataFrame and sparkSessionDataFrame
R
Anaconda R distribution
Load data into R data frame
With Spark
Load data into R data frame and sparkSessionDataFrame
With Hadoop
Load data into R data frame and sparkSessionDataFrame
Python Script
Python
Anaconda Python distribution
Load data into pandasStreamingBody
With Spark
Load data into pandasStreamingBody
With Hadoop
Load data into pandasStreamingBody
R
Anaconda R distribution
Load data into rRawObject
With Spark
Load data into rRawObject
With Hadoop
Load data into rRawObject
JSON files
Python
Anaconda Python distribution
Load data into pandasDataFrame
With Spark
Load data into pandasDataFrame and sparkSessionDataFrame
With Hadoop
Load data into pandasDataFrame and sparkSessionDataFrame
R
Anaconda R distribution
Load data into R data frame
With Spark
Load data into R data frame, rRawObject and sparkSessionDataFrame
With Hadoop
Load data into R data frame, rRawObject and sparkSessionDataFrame
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review your cookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.