【发布时间】:2018-04-04 00:34:35
【问题描述】:
我从 Google Bigquery 中提取了一个 2 列 1000 万行的 .csv 文件。
我已经在本地下载了 .csv 文件,大小为 170Mb,然后我将文件上传到 Google Drive,我想使用 pandas.read_csv() 函数将其读入我的 Jupyter Notebook 中的 pandas DataFrame。
这是我使用的代码,带有我想读取的特定文件 ID。
# read into pandasDF from .csv stored on Google Drive.
follow_network_df = pd.read_csv("https://drive.google.com/uc?export=download&id=1WqHWdgMVLPKVbFzIIprBBhe3I9faq4HA")
170Mb 的 csv 文件似乎被读取为 html 链接?
当我用另一个 40Mb 的 csv 文件尝试相同的代码时,它运行良好
# another csv file of 40Mb.
user_behavior_df = pd.read_csv("https://drive.google.com/uc?export=download&id=1NT3HZmrrbgUVBz5o6z_JwW5A5vRXOgJo")
谁能给我一些关于差异的根本原因的提示? 关于如何从在线存储中读取 1000 万行和 170Mb 的 csv 文件的任何想法?我知道仅使用 BigQuery 接口或从本地计算机就可以将 1000 万行读入 pandasDF,但我必须将其作为我提交的一部分,因此我只能从在线资源中读取。
【问题讨论】:
-
170mb 文件没有加载,但它看起来在 html 中给出了病毒警告。请复制和粘贴代码,因为图像根本没有帮助....
-
@johnashu 嗨,老实说,我唯一遇到问题的代码行是:
follow_network_df = pd.read_csv("https://drive.google.com/uc?export=download&id=1WqHWdgMVLPKVbFzIIprBBhe3I9faq4HA")括号内的 url 可用于访问谷歌驱动器上的文件。谢谢 -
@johnashu 我通过使用 Dropbox 链接来解决这个问题。
-
分块读取
标签: python pandas csv google-drive-api google-bigquery