You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Insert CSV with --detect-types crashes for CSV files that contain only a header row #702
I exported an empty table to csv, so that the csv file contains only the header row. When trying to create an SQLite DB file from that, using sqlite-utils insert "$dbfile" "$table" "$csvfile" --csv --detect-types
I run into this error:
File "/root/.local/pipx/venvs/sqlite-utils/lib/python3.11/site-packages/sqlite_utils/cli.py", line 1244, in insert
insert_upsert_implementation(
File "/root/.local/pipx/venvs/sqlite-utils/lib/python3.11/site-packages/sqlite_utils/cli.py", line 1128, in insert_upsert_implementation
db[table].transform(types=tracker.types)
File "/root/.local/pipx/venvs/sqlite-utils/lib/python3.11/site-packages/sqlite_utils/db.py", line 1780, in transform
assert self.exists(), "Cannot transform a table that doesn't exist yet"
AssertionError: Cannot transform a table that doesn't exist yet
If I run it without --detect-types, then the issue naturally does not occur.
If --detect-types is going to be the default in the future, then I would suggest fixing this, for example by making the following change in cli.py on line 1179: if tracker is not None and db.table(table).exists():
Activity
Fix issue simonw#702: Handle CSV with only header row in --detect-types
Fix: CSV insert with --detect-types crashes on header-only CSV
fix: avoid detect-types transform crash on header-only CSV
Skip type detection when CSV insert created no table
Fix issue #702: Handle CSV with only header row in --detect-types (#707)
Test for CSV headers with memory command, refs #702, #707
Release 4.0rc1
Release 4.0rc1