添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
酷酷的煎鸡蛋  ·  Golang WebSocket Ping ...·  3 月前    · 
强健的柿子  ·  Github Codespace初体验 | ...·  6 月前    · 
胆小的创口贴  ·  黑料网 - ...·  7 月前    · 
从未表白的眼镜  ·  name 'device' is not ...·  7 月前    · 
聪明伶俐的橡皮擦  ·  curl -如何转义< ...·  1 年前    · 

My first thought was to have the notebook servers automatically set up a file server and just to save the files there.  Then the notebook could give users the URL to the file via the file server. I’m sure this would work, but it requires extra components and would require some clean-up of old files now and then.

While searching online, I found this solution which is much more elegant (though it will take a little extra memory).

It base64 encodes the content and provides a link to it that way (the link actually contains all the data).  You can find the original article from medium by clicking here .  It has some other options as well.  I changed the display line and added an extra import and some altered CSV generation arguments; aside from that it is theirs.

import base64 def create_download_link( df, title = "Download CSV file", filename = "data.csv"): csv = df.to_csv(index=False, line_terminator='\r\n') b64 = base64.b64encode(csv.encode()) payload = b64.decode() html = '<a download="{filename}" href="data:text/csv;base64,{payload}" target="_blank">{title}</a>' html = html.format(payload=payload,title=title,filename=filename) return HTML(html) display(create_download_link, your_data_frame)