Skip to content
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

Error when column has colon in the column (:) name #11

Open
aseques opened this issue Aug 4, 2023 · 3 comments
Open

Error when column has colon in the column (:) name #11

aseques opened this issue Aug 4, 2023 · 3 comments

Comments

@aseques
Copy link

aseques commented Aug 4, 2023

I am trying to csv-sqlite to perform some cleanup on a csv file, and I'm having trouble when loading a csv with a colon in the name:

#no issue here echo "ID,Title,test" > a.csv cat a.csv | csv-sqlite "select * from input" -s #error here echo "ID,Title,test:" > a.csv cat a.csv | csv-sqlite "select * from input" -s #error here echo "ID,Title,\"test:\"" > a.csv cat a.csv | csv-sqlite "select * from input" -s

It prints the message:

unsupported type '"'
EOF while reading header

And exits with exit code 2, I tried with current trunk (a39e4e6)

@mslusarz
Copy link
Owner

Right, that's sort of by design because csv-nix-tools assumes an extension to the CSV format, where the colon in the column name is a type delimiter - if there's no type after :, it doesn't know what to do. This extension is crucial for many things to work (like sorting numerically or filtering numerical columns using e.g. greater-than operator), so I'm not sure what should be done about it.

One way would be to have a command line switch, which disables type parsing, but that doesn't really solve the real issue. Ignoring type parsing problems (here, it's just an empty string) could be an option, but I don't like when tools fail silently...
Maybe a better error message could be a solution? Or some combination of all 3 options?

Sorry for taking so much time to reply. I'm in the middle of a sort of hurricane right now ;).

@aseques
Copy link
Author

aseques commented Aug 16, 2023

Hi @mslusarz thanks for your answer, hope you're fine. I never heard of that csv extension until now, i just looked around and only found this but it seems to add the types also in the cells.
What I would do (of course this is only an suggestion) would be:

  • Validate the csv headers to see if it is using colons as data type specifiers, then
  • If format is OK, proceed as you are currently doing
  • If format is non compliant, issue a warning and fall back to non extended format (having a flag to force non extended would be cool)

@mslusarz
Copy link
Owner

I implemented it like you proposed in #12. I have to write more tests for that, so only PR for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants