[英]How can I read a csv file from Dropbox Online?
How can I read a csv file from Dropbox Online (without downloading it to local machine)?如何从 Dropbox Online 读取 csv 文件(无需将其下载到本地计算机)?
I installed and imported dropbox
in Python, created an app and got a token from "https://www.dropbox.com/developers/apps".我在 Python 安装并导入了dropbox
,创建了一个应用程序并从“https://www.dropbox.com/developers/apps”获得了一个令牌。 While I read some resources online, I am still fuzzy on how I move from here.虽然我在网上阅读了一些资源,但我仍然不清楚如何离开这里。
Line 149
on the example here provides a function that downloads a file and returns it as a byte string.此处示例的第149
行提供了一个 function 下载文件并将其作为字节字符串返回。
https://github.com/dropbox/dropbox-sdk-python/blob/main/example/updown.py https://github.com/dropbox/dropbox-sdk-python/blob/main/example/updown.py
Then just parse the byte string, for example using pandas
:然后只需解析字节字符串,例如使用pandas
:
import pandas as pd
from example.updown import download # import the download function from updown.py, or copy or replicate that function, I'm only providing pseudo code here
file_as_bytes = download(dbx, folder, subfolder, name)
df = pd.read_csv(file_as_bytes)
print(df)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.