2

How do you get FileLink(filename) to work in Google Colab in order to generate a download link? Is there a better way than FileLink?

Right now this code generates a download link pointing to localhost:

import pandas as pd
from IPython.display import FileLink, FileLinks

df = pd.DataFrame([[1,2,3],[4,5,6]])
df.to_csv('mydf.csv', index=False)
FileLink('mydf.csv')

The link generated as output points to: https://localhost:8080/myfile.csv

How do I get it to point to the correct file?

Ivan Vaghi
  • 21
  • 1
  • 2

1 Answers1

3

Try:

from google.colab import files
files.download('mydf.csv')

Or, more simply, use the file browser in the left hand pane.

enter image description here

dzieciou
  • 4,049
  • 8
  • 41
  • 85
Bob Smith
  • 36,107
  • 11
  • 98
  • 91
  • Thanks. It doesn't fully answer the question (how to generate dynamic file links in colabra), but it solves my problem! :-) – Ivan Vaghi Nov 19 '18 at 15:42