Closed niklaswallerstedt closed 3 years ago
I ran into this same thing, the type inference is wrecking the output, BUT the type inference is required for sorting to infer numeric values. @niklaswallerstedt thanks for posting the sort
version, I just ended up re-ordering my csv columns so that the field I wanted to sort by was first, and sort -nt,
did the job. Bummer that csvsort
couldn't do it.
@brewingcode I'm glad I could help.
I saw this mentioned in the docs
If your file is large, try sort -t, file.csv instead.
but I agree it would be great to be able to pass --numerical
in conjunction with -I
(-n
is already in use) or something similar to preserve the output.
I think we would need to be able to enable inference on only specific columns, which is the topic of #151. Adding something like --numerical
would essentially be the same thing. #151 has the advantage that it would build on existing code, rather than adding a specific code path just for csvsort
.
Closing in favor of #151.
I'm trying to sort a list of customer ids numerically, a sort of similar issue is #637.
Given this made up list
If I run this:
the sorting is working as expected, except for the type-inference messing with the values.
Tried this:
However, quite expected the sorting is no longer numerical.
How do I keep the numerical sort but preserve the values that
--no-inference
gets me?And.. as I was typing this up, this does what I want: