On Thu, Jul 30, 2015 at 9:00 PM, Roger Binns <rogerb at rogerbinns.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 07/30/2015 10:58 AM, Sylvain Pointeau wrote: > > is it possible? in a lot of cases, I cannot use sqlite (executable) > > because of the lack of a good CSV import. It would really great if > > this could be addressed. > > Use the APSW shell: > > http://rogerbinns.github.io/apsw/shell.html > > Behind the scenes it uses the Python CSV libraries which support a > number of dialects including excel (default) and excel-tab. > > The APSW shell also supports an .autoimport command. It automatically > works out dialects, separators and data types. Here is the extended help: > > ==== 8< ==== > sqlite> .help autoimport > > .autoimport FILENAME ?TABLE? Imports filename creating a table > and automatically working out > separators and data types > (alternative to .import command) > > .... > > Care is taken to ensure that columns looking like numbers are > only treated as numbers if they do not have unnecessary leading > zeroes or plus signs. This is to avoid treating phone numbers > and similar number like strings as integers. I know your shell, unfortunately it is more difficult to install Python and APSW than just bare sqlite3. Additionally it works well (see my previous email, I was wrong, the CSV import works just fine) however your auto import reminds me just what I faced few days ago, leading 0 are removed when opening a csv file by double clicking on it to open it in excel. I had to do import -> data then to go through the wizard until I setup all columns as text, to keep the leading 0. unfortunately it led to another issue, cell with multiple lines where badly imported. what I did, I removed the line feed on some columns before generating the csv. not easy to have all we need :-/