-
-
Notifications
You must be signed in to change notification settings - Fork 117
--no-headers option for CSV and TSV #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I could combine this with #131 to allow types to be specified in addition to column names. Probably need an option that means "ignore the existing heading row and use this one instead". |
For the moment, a workaround can be to
|
I'm going to detach this from the #131 column types idea. The three things I need to handle here are:
Here's a potential design that covers the first two:
It doesn't cover the "give me unknown column names" case though. |
Another pattern that might be useful is to generate a header that is just "unknown1,unknown2,unknown3" for each of the columns in the rest of the file. This makes it easy to e.g. facet-explore within Datasette to figure out the correct names, then use I needed to do that for the https://bl.iro.bl.uk/work/ns/3037474a-761c-456d-a00c-9ef3c6773f4c example. |
I just spotted that |
Implementation tip: I have code that reads the first row and uses it as headers here: sqlite-utils/sqlite_utils/cli.py Lines 689 to 691 in 8f042ae
So If I want to use |
I'm not convinced the def has_header(self, sample):
# Creates a dictionary of types of data in each column. If any
# column is of a single type (say, integers), *except* for the first
# row, then the first row is presumed to be labels. If the type
# can't be determined, it is assumed to be a string in which case
# the length of the string is the determining factor: if all of the
# rows except for the first are the same length, it's a header.
# Finally, a 'vote' is taken at the end for each column, adding or
# subtracting from the likelihood of the first row being a header. |
For the moment I think just adding Users can import with that option, then use |
I called this sqlite-utils/sqlite_utils/cli.py Lines 61 to 64 in 427dace
|
|
https://bl.iro.bl.uk/work/ns/3037474a-761c-456d-a00c-9ef3c6773f4c has a fascinating CSV file that doesn't have a header row - it starts like this:
It would be useful if
sqlite-utils insert ... --csv
had a mechanism for importing files like this one.The text was updated successfully, but these errors were encountered: