Google BigQuery-导入CSV-如何匹配列? [英] Google BigQuery - Import CSV - How to match columns?

查看:72
本文介绍了Google BigQuery-导入CSV-如何匹配列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我定期通过CSV导入BigQuery,效果很好.

CSV文件格式为:

  • [第一行]-标头=与列完全匹配的列名我要导入的BigQuery表中的名称

  • [其余各行] =数据

但是,我的CSV中的列顺序最近已更改,并且在导入到BigQuery时-CSV中的列名与BigQuery表中的列名不匹配.它们基本上是按CSV列的顺序导入的,这是错误的.

有没有办法告诉BigQuery我的CSV哪一列转到BigQuery表中的哪一列?

我正在使用官方的PHP库.

示例: https://github.com/GoogleCloudPlatform/php-docs-samples/blob/master/bigquery/api/src/functions/import_from_file.php

解决方案

CSV导入与列名不匹配(假设您使用第一行来命名列).

您能做的最好的事情是将其导入与新文件的列顺序匹配的其他表中,然后运行SELECT,将重新排序的列输出到现有表中.

I have regular imports going to BigQuery via CSV which work fine.

The CSV file format is:

  • [1st line] - header = column names which match exactly the column names in the BigQuery table I am importing to

  • [rest of the lines] = the data

However, the order of the columns in my CSV has recently changed and when importing to BigQuery - the column names in CSV are not matched to column names in BigQuery table. They get basically imported in the order of the CSV columns which is wrong.

Is there a way to tell BigQuery which column from my CSV goes to which column in BigQuery table?

I am using the official PHP library.

Example: https://github.com/GoogleCloudPlatform/php-docs-samples/blob/master/bigquery/api/src/functions/import_from_file.php

解决方案

CSV import won't match the name of the columns (assuming you are using the first row to name the columns).

The best you could do is import into a different table which matches the column order of the new files, and then run a SELECT that will output the re-ordered columns into the existing table.

这篇关于Google BigQuery-导入CSV-如何匹配列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆