Last active
January 18, 2020 03:48
-
-
Save ZeccaLehn/6d4b8a4ae31c00aa8841457c48b8e28b to your computer and use it in GitHub Desktop.
CSV Download and Upload Collab Jupyter Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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