Phil Scarratt wrote:
> An extract from the MySQL manual under the LOAD DATA INFILE section:
> -- SNIP --
> An empty field value is interpreted differently than if the field value is missing:
>     * For string types, the column is set to the empty string.
>     * For numeric types, the column is set to 0.
> * For date and time types, the column is set to the appropriate ``zero'' value
> for the type. See section 6.2.2 Date and Time Types.
> 
> Note that these are the same values that result if you assign an empty string
> explicitly to a string, numeric, or date or time type explicitly in an INSERT or
> UPDATE statement.
> -- SNIP --
> 
> A script to parse the data file sounds like the way to go.

Looks like thats what I need to do. I did a search on MyQL mail archives
and 
didnt really turn up much (I have subscribed now to the mailing list)
but reading between 
the lines of the manual and FAQs it looks like I have to use a \N in the
text file.

Replace all "" with "\N" in csv files:
  for i in *.csv; do cat $i | sed 's/""/"\\N"/g' > tmp; mv tmp $i; done

which I have now done and all 8,400 lines are in teh database with no
eerors.

Thanks and byes from Mike

-- 
--------------------------------------------------------------------
Michael Lake
Active caver, Linux enthusiast and interested in anything technical.
--------------------------------------------------------------------
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to