<p>这就是我现在从web加载.gz的方式:</p>
<pre><code>import gcp.bigquery as bq
import gcp.storage as storage
f = urllib.urlopen(url)
storage.Bucket('mybucket').item(gcs_url).write_to(f.read(), 'application/x-gzip')
table = bq.Table('%s.%s' % (dataset_name, table_name)).create(schema=schema, overwrite = True)
table.load_async(
'gs://mybucket/%s' % gcs_url, mode='overwrite', csv_delimiter=' ', quote='', max_bad_records=100)
</code></pre>
<p>这将下载位于<a href="https://dumps.wikimedia.org/other/pagecounts-raw/2015/2015-01/" rel="nofollow">https://dumps.wikimedia.org/other/pagecounts-raw/2015/2015-01/</a>的gz文件。在</p>
<p>观察结果:</p>
<ul>
<li><p>我找不到一个简单的方法来下载和上传文件。取而代之的是,我把整个东西放在RAM中(~100GB)。它在这个用例中工作得很好,但对于较大的文件来说并不理想。</p></li>
<li><p>在将数据加载到表中之前,我先创建表。我不知道如何同时执行这两个操作(因此BigQuery有一段时间是空表)。</p></li>
<li><p>当我使用load_async时,我希望有一个简单的方法来等待所有作业完成。</p></li>
<li><p>有什么简单的方法来集成<a href="https://cloud.google.com/monitoring/" rel="nofollow">https://cloud.google.com/monitoring/</a>,这样当工作完成时它会给我页面吗?</p></li>
</ul>
<p>(问题跟踪程序<a href="https://github.com/GoogleCloudPlatform/datalab/issues/198" rel="nofollow">https://github.com/GoogleCloudPlatform/datalab/issues/198</a>)</p>