Re: load data infile somewhat flaky

Johann Klammer <[email protected]> Wed, 18 Aug 2021 10:10:26 +0200
Newsgroups comp.databases.mysql
Organization Aioe.org NNTP Server
Message-ID <[email protected]>
On 08/17/2021 07:11 PM, DFS wrote:
> Finally got a big file (3 columns x 612K rows) of messy data loaded.
> 
> load data infile 'file.csv'
> into table
> fields terminated by ','
> enclosed by '"';
> 
> I noticed it tells you an error occurred at a certain line, but the offending data (a text field ending in \ or "\") 5 lines later was the real issue.
> 
> On one run 5 lines didn't post, and it turns out they were the next 5 lines after a field ending in "\".  Those 5 lines got concatenated with the offending line, so I had one large clump of data in one row.
> 
> Moral: watch for fields ending in \ or "\".
> 
I seem to recall it also has problems with whitespace around the commata.