Skip to content

Instantly share code, notes, and snippets.

@ZeccaLehn
Last active March 7, 2019 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZeccaLehn/8cd32a95bd68a955dbc7a5eb222f80e7 to your computer and use it in GitHub Desktop.
Save ZeccaLehn/8cd32a95bd68a955dbc7a5eb222f80e7 to your computer and use it in GitHub Desktop.
Download CSVs Directly from JupyterNotebook or Google DataLab
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