熊猫:如何从Google Drive Public读取CSV文件?

astro123

我搜索了有关从URL读取csv的类似问题,但找不到从Google驱动器csv文件读取csv文件的方法。

我的尝试:

import pandas as pd

url = 'https://drive.google.com/file/d/0B6GhBwm5vaB2ekdlZW5WZnppb28/view?usp=sharing'
dfs = pd.read_html(url)

我们如何在熊猫中读取此文件?

相关链接:

astro123

另一种方式:

import pandas as pd
import requests
from io import StringIO

orig_url='https://drive.google.com/file/d/0B6GhBwm5vaB2ekdlZW5WZnppb28/view?usp=sharing'

file_id = orig_url.split('/')[-2]
dwn_url='https://drive.google.com/uc?export=download&id=' + file_id
url = requests.get(dwn_url).text
csv_raw = StringIO(url)
dfs = pd.read_csv(csv_raw)
print(dfs.head())

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Google Drive 用户无权读取文件

Google Drive API:如何从Google Drive下载文件?

如何在python的内存中从Google Drive读取(流)文件?

从Google Drive URL用熊猫读取CVS时出错

使用 Pandas(Python) 从 Google Drive 读取非常大的 csv 文件

如何从项目Google Drive浏览文件

如何使用Google Drive API上传文件?

Google Colaboratory中的Python-如何在Google Drive中创建,写入和读取文件

熊猫:如何从CSV文件读取特定行

熊猫:如何从CSV或Excel文件读取行?

Google Drive API附加文件?

Google Drive API文件搜索

文件上传到 Google Drive

使用 pydrive 或 google drive api 在 google drive 中复制文件

使用Google Drive API在指定的Google Drive中上传文件

如何停止 Google Sheets 自動將下載的 CSV 文件保存到 Google Drive

如何使用Google Drive API将文件上传到Google Drive?

如何使用Google Drive Javascript API更新Google Drive中的zip文件

如何使用Google Drive Java API v3在Google Drive上复制文件?

如何使用google drive api获取google drive中所有文件的名称?

如何使用PHP Google Drive API在Google Drive上上传文件

如何使用python google drive api将文件夹上传到共享的google drive?

如何使用 Google Drive API for python 与多个用户共享来自 Google Drive 的文件?

如何通过Android的Drive API读取Google表格内容?

将“.csv”文件从 Google Drive 导入 Jupyter Notebook

如何从CSV文件读取

如何使用 Google Drive API 上传我的 Drive (PHP) 中的文件?

将Google Drive API与Java结合使用,如何仅列出Drive Section / Folder中的文件

如何使用Google的Python Drive Client API在Team Drive中创建文件夹?