Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#71 Handling NULL Values

open
nobody
None
5
2011-06-06
2011-06-06
Anonymous
No

Hi,

I'm using mysql "select into outfile" to create csv style textfile.
Example:
SQL: mysql>
select *
into outfile '/tmp/records.out'
FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n'
from data2unload;

I've instantiaed opencsv as p = new CSVParser(',', '"', '\\');

Everything is great until the source table has NULLs.

These are encoded as \N without the "enclosed by character" in the csv file.

Example:
"varchar\"', simple\\","N","2011-06-06 12:06:38",\N,\N,\N

currently opencsv returns the string 'N' as value for those fields.

Is there already a NULL handling implemented? I couldn't find anything.

How hard would it be to add a special handling (return a null object) for those \N without enclosing chracters?

Thanks Thomas

Discussion