Skip to content

Instantly share code, notes, and snippets.

@ZeccaLehn
Last active January 18, 2020 03:48
Show Gist options
  • Save ZeccaLehn/6d4b8a4ae31c00aa8841457c48b8e28b to your computer and use it in GitHub Desktop.
Save ZeccaLehn/6d4b8a4ae31c00aa8841457c48b8e28b to your computer and use it in GitHub Desktop.
CSV Download and Upload Collab Jupyter Python
## Download
from google.colab import files
df.to_csv('df.csv')
files.download('df.csv')
## Upload
from google.colab import files
df = files.upload()
## Save CSV on remotely in Colab
import pandas as pd
from IPython.display import FileLink, FileLinks
import os
data = df
directory = 'data/'
filename = 'data.csv'
pathtofile = directory + filename
if not os.path.exists(directory):
os.makedirs(directory)
else:
print('Directory already exists')
data.to_csv(pathtofile, index = True)
FileLinks(directory)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment