首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用BigQuery将表数据导出到XLS文件是可行的吗?

问使用BigQuery将表数据导出到XLS文件是可行的吗?
EN

Stack Overflow用户
提问于 2022-03-21 08:48:10
回答 1查看 236关注 0票数 -1

BigQuery支持将表数据导出到CSV。但是,我想将结果导出到xls。有什么方法导出XLS格式吗?

代码语言:javascript
复制
// Import the Google Cloud client libraries
const {BigQuery} = require('@google-cloud/bigquery');
const {Storage} = require('@google-cloud/storage');

const bigquery = new BigQuery();
const storage = new Storage();

async function extractTableToGCS() {
  // Exports my_dataset:my_table to gcs://my-bucket/my-file as raw CSV.

  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const datasetId = "my_dataset";
  // const tableId = "my_table";
  // const bucketName = "my-bucket";
  // const filename = "file.csv";

  // Location must match that of the source table.
  const options = {
    location: 'US',
  };

  // Export data from the table into a Google Cloud Storage file
  const [job] = await bigquery
    .dataset(datasetId)
    .table(tableId)
    .extract(storage.bucket(bucketName).file(filename), options);

  console.log(`Job ${job.id} created.`);

  // Check the job's status for errors
  const errors = job.status.errors;
  if (errors && errors.length > 0) {
    throw errors;
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-21 10:19:36

BigQuery存储您的数据。当您导出它们时,将以CSV、JSON或其他方式导出数据。这是原始数据。

什么是excel格式?它是原始数据,有额外的元数据信息来格式化单元格,有不同的表格,.

BigQuery只知道数据,不知道要添加的元数据。因此,在export-to-CSV-then-import-data-from-CSV-in-Google-Sheet).中没有内置功能可以导出到BigQuery (导出到Google只是BigQuery的一个快捷方式)。您需要格式化您自己的文件,因此对其进行编码。(如果要创建PDF,则相同)

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71554866

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档