Importing data from flat files

DataLab features a library of curated datasets ready for you to analyze, but it is also possible to work with your own data files, be it CSV, Excel, text, geospatial, etc. data files. In this article, we'll assume that the data file you want to work with in DataLab is on your computer. The first step is uploading the file to DataLab, the next step is loading the data file into your notebook session.

Uploading the data file

  • To upload the data file, you have several options:

    • Click on "Browse files" in the dashed rectangular box in the file browser. Select the file from your local filesystem and confirm.

    • Drag the file from a file browser (Windows) or Finder (Mac) window into the file browser pane.

Loading the data file into your notebook session

Now that you have uploaded to file to your workbook, you can load it into your session so you can start analyzing it.

Second, add a new code cell to your notebook file and add one of the following code snippets depending on the file format or the language you're using. Note that you may need to tweak this function call to deal with the specifics of your file (e.g. to skip rows, to specify the column names, etc). Replace example.csv with the file path you copied to your clipboard in the first step.

File TypePythonR


import pandas as pd pd.read_csv('example.csv')

import readr read_csv('example.csv')


import pandas as pd pd.read_excel('example.xlsx')

import readxl read_excel('example.xlsx')

Finally, run the code cell. The data contained in the file will now be available as a dataframe df that you can start analyzing.

Shortcut for CSV files

Last updated