Not sure I buy your test cases.

Fields containg double quotes must be in double quotes.  So only one of your 
examples is valid

first,""second"",third

I'll have to fix that one.



I could add the CR/LF...but I've never seen that used in a CSV format.  Then 
again, may as well use the standard.  That's the nice thing about 
standards...there are so many to choose from :-)





Michael D. Black

Senior Scientist

Advanced Analytics Directorate

Advanced GEOINT Solutions Operating Unit

Northrop Grumman Information Systems

________________________________
From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Simon Slavin [slav...@bigfraud.org]
Sent: Sunday, May 06, 2012 8:35 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] is SQLite the right tool to analyze a 44GB file


On 6 May 2012, at 1:59pm, "Black, Michael (IS)" <michael.bla...@ngc.com> wrote:

> I modified my csvimport to allow for quoted fields.  Still automaticallhy 
> detects the # of columns.
> If quoted fields also contain internal quotes they must be escaped by 
> doubling them.
> e.g.
> col1,"this is, a ""quoted"" field",col3

I trust you as a competent programmer, but I have test cases for you:

first",second,"third
first,""second,third
first"",second,third
first,""second"",third
first,""second,""third
first"",second,""third
first"",second"",third

producing error messages (or how many columns are filled) is up to you.

> It's not fully RFC4180 compliant as it doesn't allow for CF/LF inside quotes 
> -- does anybody really need/use that?

Yes, in that I have multi-line address fields and multi-paragraph notes fields. 
 But we don't store that data in CSV files, so it wouldn't matter that a CSV 
import tool couldn't handle it.  Actually that system uses MySQL not SQLite.  
Might be interesting to see if the SQLite shell tool failed to handle it.

We had a lot of discussion about allowing CR (which is the character we use) 
but decided that multi-paragraph notes fields was an idea whose time had come.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to