# Importing data from flat files

DataLab features a [library of curated datasets](https://app.datacamp.com/workspace/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

* Click on "File > show workbook files" in the menu.
* To upload the data file, you have several options:
  * Click on "Add" in the top right of the file browser pane and click "Upload". Select the file from your local filesystem and confirm.
  * 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.&#x20;

First, copy the file path to your clipboard: in the workbook file browser, click the <img src="/files/kp68fCRN6A77NTG8bwJt" alt="" data-size="line"> icon next to the data file and click "Copy path to clipboard".

Next, 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.

<table><thead><tr><th width="123">File Type</th><th>Python</th><th>R</th></tr></thead><tbody><tr><td>CSV</td><td>import pandas as pd<br>pd.read_csv('example.csv')</td><td>import readr<br>read_csv('example.csv')</td></tr><tr><td>Excel</td><td>import pandas as pd<br>pd.read_excel('example.xlsx')</td><td>import readxl<br>read_excel('example.xlsx')</td></tr></tbody></table>

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

Specifically for CSV files, there is a faster way: click the <img src="/files/kp68fCRN6A77NTG8bwJt" alt="" data-size="line"> icon next to the file you want to import and select "Load as DataFrame". A new code cell will be added to your notebook with the appropriate Python or R code.

<figure><img src="/files/gP7gfDfWj46bE77hFvGc" alt="" width="338"><figcaption><p>"Load as DataFrame" is a quick way to import a CSV file into your notebook</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://datalab-docs.datacamp.com/guides/importing-data-from-flat-files.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
