rows_from_file() splits a single-column CSV file on a letter, or raises csv.Error

Open Beginner friendly
#907 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@L4XB is already working on this.

Since Oct 17, 2026.

  • #908 by @L4XB — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, sqlite
Domain
cli, data

Research direction

Locate rows_from_file() and reproduce the single-column CSV cases with the sqlite-utils memory commands shown in the issue. Check how delimiter detection is performed, then run the relevant existing tests and add coverage for single-column CSV input with headers and URLs. The work is done when files without a recognized delimiter are imported as one column, while insert --sniff behavior remains unchanged.

Written by the indexing model from the issue text.

Description

When rows_from_file() detects the format of a single-column CSV file, it either fails or splits the column on a letter. That affects sqlite-utils memory file.csv and any Python call that leaves format= unset.

$ printf 'name\nAnn\nBob\n' > names.csv
$ sqlite-utils memory names.csv "select * from names"
...
_csv.Error: Could not determine delimiter

$ printf 'url\nhttps://example.com/a\nhttps://example.org/b\n' > urls.csv
$ sqlite-utils memory urls.csv "select * from urls"
[{"ur": "https://examp", "": "e.com/a"},
 {"ur": "https://examp", "": "e.org/b"}]

(sqlite-utils 4.2.1)

The detection calls csv.Sniffer().sniff() on the first 2048 bytes without a delimiters= list. The sniffer then treats any character as a candidate, so a file with a single column either has no consistent candidate (csv.Error) or has a letter that happens to repeat the same number of times on every line (l above).

A fix could sniff only for the delimiters a CSV file is realistically written with (,, ;, tab, |) and read the file as one column when none of them is found. insert --sniff calls the sniffer the same way, but that is an explicit request to detect the dialect, so I would leave it unchanged.

Dominant language
Python
Stars
2.2k
Forks
215
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from simonw/sqlite-utils

All issues in simonw/sqlite-utils

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.