mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 09:54:31 +02:00
--empty-null option for CSV and TSV imports, closes #563
This commit is contained in:
parent
63dc7ab1a5
commit
f7af23837d
5 changed files with 55 additions and 2 deletions
|
|
@ -266,6 +266,7 @@ See :ref:`cli_inserting_data`, :ref:`cli_insert_csv_tsv`, :ref:`cli_insert_unstr
|
|||
--nl Expect newline-delimited JSON
|
||||
-c, --csv Expect CSV input
|
||||
--tsv Expect TSV input
|
||||
--empty-null Treat empty strings as NULL
|
||||
--lines Treat each line as a single value called 'line'
|
||||
--text Treat input as a single value called 'text'
|
||||
--convert TEXT Python code to convert each item
|
||||
|
|
@ -321,6 +322,7 @@ See :ref:`cli_upsert`.
|
|||
--nl Expect newline-delimited JSON
|
||||
-c, --csv Expect CSV input
|
||||
--tsv Expect TSV input
|
||||
--empty-null Treat empty strings as NULL
|
||||
--lines Treat each line as a single value called 'line'
|
||||
--text Treat input as a single value called 'text'
|
||||
--convert TEXT Python code to convert each item
|
||||
|
|
@ -372,6 +374,7 @@ See :ref:`cli_bulk`.
|
|||
--nl Expect newline-delimited JSON
|
||||
-c, --csv Expect CSV input
|
||||
--tsv Expect TSV input
|
||||
--empty-null Treat empty strings as NULL
|
||||
--lines Treat each line as a single value called 'line'
|
||||
--text Treat input as a single value called 'text'
|
||||
--convert TEXT Python code to convert each item
|
||||
|
|
|
|||
16
docs/cli.rst
16
docs/cli.rst
|
|
@ -1281,6 +1281,22 @@ You can set the ``SQLITE_UTILS_DETECT_TYPES`` environment variable if you want `
|
|||
|
||||
export SQLITE_UTILS_DETECT_TYPES=1
|
||||
|
||||
If a CSV or TSV file includes empty cells, like this one:
|
||||
|
||||
.. code-block:: csv
|
||||
|
||||
name,age,weight
|
||||
Cleo,6,
|
||||
Dori,,3.5
|
||||
|
||||
They will be imported into SQLite as empty string values, ``""``.
|
||||
|
||||
To import them as ``NULL`` values instead, use the ``--empty-null`` option:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sqlite-utils insert creatures.db creatures creatures.csv --csv --empty-null
|
||||
|
||||
.. _cli_insert_csv_tsv_delimiter:
|
||||
|
||||
Alternative delimiters and quote characters
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue