Open hubgit opened 2 years ago
A couple of tricks I use here. Firstly, I often create the table before the import using the sqlite-utils create-table
command: https://sqlite-utils.datasette.io/en/stable/cli.html#creating-tables
The other current option is to use the bulk
command, which lets you construct a custom SQL query to execute against every row from a CSV file: https://sqlite-utils.datasette.io/en/stable/cli.html#executing-sql-in-bulk
Do either of those options work here or is there a useful new feature that would work better?
Creating the table before inserting is a useful workaround, thanks. It does require figuring out the create table
syntax and listing all the fields manually, though, which loses some of the magic of sqlite-utils.
I was expecting to find an option like --headers=foo,bar
(or --header-row='foo\tbar'
, if that would be easier) - not necessarily that exact syntax, but something that would essentially be treated the same as having a header row in the file.
Yeah, having a way of inserting a CSV file but saying "only I want the title
column to come first" does make sense to me as a feature.
It can use -o
for consistency with https://sqlite-utils.datasette.io/en/stable/cli-reference.html#search and https://sqlite-utils.datasette.io/en/stable/cli-reference.html#rows and https://sqlite-utils.datasette.io/en/stable/cli-reference.html#transform
https://sqlite-utils.datasette.io/en/stable/cli.html#csv-files-without-a-header-row
It would be nice to be able to specify the column names when importing CSV/TSV without a header row, via an extra command line option.
(renaming a column of a large table can take a long time, which makes it an inconvenient workaround)