0
votes

I have an automated job which uploads CSV file into BigQuery table every day. It works fine, however, every time I do do import, it inserts the header (first row) as values into the table which I don't want. I have to use the header so BigQuery knows how map the column names. Is there a way to somehow specify "skip first row" or something like that?

I am using this function to do the import:

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

1

1 Answers

4
votes

It sounds like you want to set the skipLeadingRows option. Referring to the example that you linked, it would be something like this:

$options['jobConfig'] = [
  'sourceFormat' => 'CSV',
  'skipLeadingRows' => 1
];

This will skip the first row in the CSV file (which contains the header) when you initiate the load job.