I'm trying to import the geonames database (http://download.geonames.org/export/dump/ specifically the unzipped allCountries.zip file) as follows:
-- yet another attempt to create geonames "quickly" wo a perl script
CREATE TABLE geonames (
geonameid,
name,
asciiname,
alternatenames,
latitude,
longitude,
featureclass,
featurecode,
countrycode,
cc2,
admin1code,
admin2code,
admin3code,
admin4code,
population,
elevation,
dem,
timezone,
modificationdate DEFAULT ''
);
.bail OFF
.separator "\t"
.import allCountries.txt geonames
I get this error:
Error: allCountries.txt line 374993: expected 19 columns of data but found 18
I understand the error: some lines in allCountries.txt have fewer than 19 fields (the last field(s) are assumed blank/null).
Can I easily force SQLite3 to treat missing import fields as blank/null?
I realize I can write a Perl script, etc, but I'm curious if this can be done purely in SQLite?
Note that neither ".bail OFF" nor setting a default for the missing field works.
EDIT: I'm still curious about the answer, but it turns out this is a red herring: line 374993 contains a quotation mark, which (correctly) throws sqlite3 import off (see sqlite3 import with quotes). All lines contain 19 columns of data, however.