Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data between quotes and field separator

In the example given below, the last line is not uploaded. I get an error:

Data between close double quote (") and field separator: 

This looks like a bug since all the data between pipe symbol should be treated as a single field.

Schema: one:string,two:string,three:string,four:string

Upload file:

This | is | test only | to check quotes
second | line | "with quotes" | no text
third line | with | "start quote" and | a word after quotes

The first and second line above is processed. But not the third.


Update:

Can some please explain why does the following work except the third line?

This | is | test only | to check quotes
second | line | "with quotes" | no text
third line | with | "start quote" and | a word after quotes
forth line | enclosed | {"GPRS","MCC_DETECTED":false,"MNC_DETECTED":false} | how does this work?
fifth line | with | {"start quote"} and | a word after quotes

There can be some fancy explanation to this. From the end user perspective this is absurd.

like image 613
shantanuo Avatar asked Dec 03 '25 14:12

shantanuo


2 Answers

Using --quote worked perfectly.

bq load 
--source_format CSV --quote "" 
--field_delimiter \t 
--max_bad_records 10 
-E UTF-8   
destination table
Source files 
like image 199
Pandian Palanimuthu Avatar answered Dec 05 '25 04:12

Pandian Palanimuthu


From the CSV RFC4180 page: "If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote."

You probably want to do this:

This | is | test only | to check quotes
second | line | "with quotes" | no text
third line | with | " ""start quote"" and " | a word after quotes

More about our CSV input format here.

like image 26
Michael Manoochehri Avatar answered Dec 05 '25 03:12

Michael Manoochehri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!