If you just want to try out this integration by accessing predefined datafiles, you can skip the next part and go to the next section immediately.
If you want to access your own files, you will need to create a new app in the App Console.
First, choose for scoped access. This way you can choose what permissions your app will have, and thus what your app can do (read, write, delete...). Next, you can choose for either App folder (if you want your app to only have access to a specific folder) or Full Dropbox access (if your app can access everything in your Dropbox). If you choose for the former option, make sure to put the files you want to access into this folder. This folder will automatically be created and named after your app name. Finally, you can choose this name of your app.
On the next page, on the Permissions tab, you can now choose what permissions your app can have. To set up a basic read connection to your workspace, you will need at least the permission. When you select this option, all other required options will automatically get selected. If you also would like to write to your Dropbox files, you will also need the files.content.write permission.
When you go back to the Settings tab, you can generate your access token. Copy this access token and define it as an environment variable in your workspace as follows. If you want to learn more about environment variables and how you can store them securely in DataCamp Workspace; check out this article.
Once you have set up and connected your integration to your workspace, you can access your files from your workspace with following lines of code. You can also check out this example.
# Import the packages
import pandas as pd
import os
from io import StringIO
from dropbox import Dropbox
dbx = Dropbox(os.environ["DROPBOX_ACCESS_TOKEN"])
def read_file(file_name, index_col=None):
metadata, res = dbx.files_download(path="/"+filename)
s = str(res.content, "utf-8")
data = StringIO(s)
return pd.read_csv(data, index_col=index_col)
df = read_file("filename.csv", index_col = "index_col_name")

Sample database: online shoe retail

Without creating your own Dropbox integration as explained above, you can also use the Dropbox credentials we set up for you to try out. These credentials will give you access to three example data files. Together, they form a small dummy database of an online shoe retailer. You can find more information on these files in this template. If you want to connect to this Dropbox folder, set your environment variable as follows in the integration tab:
After setting up this integration and connecting it to your workspace, everything will be ready to run.