SQLite Forum

How to import a csv file whose columns are separated by semicolons
Login
> .separator ";"

You don't need the double quotes here. This works:

      .separator ;

> .import c: /users/inspiron/desktop/people2012.csv

Why are you putting a space between the "c:" bit and the rest of the path? That's two paths, the first meaning "the current working directory on the C drive".

I assume this isn't a literal copy-and-paste from a SQLite command session, else later parts of your explanation wouldn't be working, which then leads me to ask, why are you posting commands here that differ from what you're *actually* typing? Why make us second-guess your description in order to make any sense of it?

> duplicate column name:

It means the first row of your CSV file isn't a header, listing the names of the columns. You can pre-define the schema, as you discovered, to get around this.

Unless you depend on the column affinities being set up in a certain way, it's simpler to just add a header row to the input file. Several other programs expecting CSV/TSV style input also want that header.

> Only periods and commas appear.

...and then you go on to show semicolons and double-quotes instead. Once again, one thing is happening on your local computer, but you then go to show us something different.

I expect this is just a reflection of your earlier `.mode` selection, telling it to use semicolons as separators, and that the difference is due to restarting `sqlite3`, causing the separator and other modes to be reset to their defaults.

That is, `.separator` also affects SQLite's *output*, not just its `.csv` *input*. Be enlightened:

      .separator ' ooga booga '
      select * from people2012 limit 10;

As for the rest, SQLite is telling you the problem: the separator isn't matching somehow. Can you post a few rows of the data table somewhere?