Last active
March 7, 2019 00:11
-
-
Save ZeccaLehn/8cd32a95bd68a955dbc7a5eb222f80e7 to your computer and use it in GitHub Desktop.
Download CSVs Directly from JupyterNotebook or Google DataLab
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
import pandas as pd | |
from IPython.display import FileLinks # FileLink | |
import os | |
data = pd.DataFrame([['a', 'b'],['c', 'd'],['e','f']], columns = ['foo', 'bar']) # .values.tolist() | |
directory = 'testdata/' | |
filename = 'data2.csv' | |
pathtofile = directory + filename | |
if not os.path.exists(directory): | |
os.makedirs(directory) | |
else: | |
print('Directory already exists') | |
data.to_csv(pathtofile, index = False) | |
FileLink(directory) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment