On Tue, Sep 2, 2014 at 9:07 PM, Carlos A. Gorricho (HGSAS) <
cgorri...@heptagongroup.co> wrote:

> Dear all,
>
> I am experiencing some difficulties loading CSV data into it.
>
> I am using the precompiled binary available on the web site for Mac OSX. I
> am running OS X 10.9.4 on a Mac Book Pro.
>
> When following instructions to upload CSV on a new database:
>
> sqlite> *.mode csv*
> sqlite> *.import My-CSV-file.csv tab1*
>

What version of SQLite is installed?

Macs still default using a 2- or 3-year-old SQLite that has issues in CSV
import.  Those issues have long since been fixed in trunk.  Have you
upgraded your SQLite?


>
>
> I get an error message:
>
> sqlite> .import BD-Costes-17072014.csv tab1
>
> Error: no such table: tab1
>
> sqlite>
>
>
> I understood that if tab1 did not exist, sqlite3 would create a new one and
> use the first line in the CSV file as column headers.
>
> Then I created the table tab1:
>
> sqlite> .tables
>
> tab1
>
> sqlite> .schema
>
> CREATE TABLE tab1 (
>
> CODIGO
>
> DESCRIPCION
>
> TIPO_ARTICULO
>
> DESCRIPCION_TIPO_ARTICULO
>
> NIVEL
>
> CODIGO_MATERIAL
>
> MATERIAL
>
> CàDIGO_SUSTITUTO
>
> SUSTITUTO
>
> FACTOR
>
> FACTOR_X_SKU
>
> UNIDAD
>
> PRECIO
>
> COSTE);
>
> sqlite>
>
>
> These are the exact same headers as in my CSV file. I removed the headers
> from the CSV file and run the .import command again, apparently with no
> error.
>
> When checking for the amount of records uploaded:
>
> sqlite> select count(*) from tab1;
>
> 1
>
> sqlite>
>
> The CSV files has 2651 records. Apparently, all the records are being
> loaded as one huge string into the first db record, AND the first field:
>
> sqlite> select CODIGO from tab1 LIMIT 1;
>
> 24873,PULP DURAZNO 0.150 ML X 96,4,PRODUCTO TERMINADO,1,559,COLA PARA
> PITILLOS HOT MELT ADHESIVE JOWATERM 25030
>
> [OUTPUT GOES ON TO THE END OF THE CSV FILE...]
>
>
> Compare this with a query on the second field:
>
> sqlite> select DESCRIPCION from tab1;
>
> Error: no such column: DESCRIPCION
>
>
> I have not been able to understand what is going on. I am an intensive user
> of CSV files for analytical purposes, hence being able to upload them
> correctly into SQLite3 is key.
>
> I am suspecting maybe an environmental variable or something like that
> needs to be modified, but would not venture without guidance.
>
> Looking forward to hearing your feedback.
>
> Attached the original CSV file and resulting database.
>
>
>
> Saludos/Cheers,
>
>
> *CARLOS A. GORRICHO*
> Managing Partner
> Heptagon Group S.A.S.
> cgorri...@heptagongroup.co
> Cel COL +57 314 771 0660
> Cell USA +1 713 574 2242
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>


-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to