Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

csv field contains delimiter bq load

Hi,

I'm trying to load a csv file with the bq load command.  The file has the following contents and it is using the '~' as the delimiter:

id~name~date

200~"name1"~2025-05-20

300~"name2~last"~2025-05-20

The problem is that row 2 contains the delimiter character within the second field.  I'm loading this with the bq load command into a BigQuery table as follows:

bq load
--replace=true
--source_format=CSV
--field_delimiter="~"
--quote=""
--skip_leading_rows=1
--project_id=project-name dataset.table_name gs://file_name.csv C:/scehma.json

Error
while reading data, error message: Too many values in line. Found
4 column(s) when expecting 3.

So this is because the 2nd row contains the delimiter as part of the field contents.  However, from my understanding if the whole field is enclosed within double quotes then this should resolve the issue.  But even when enclosing the entire field contents within double quotes I'm still getting the error.

Hope someone can help.

0 0 29
0 REPLIES 0