-
Notifications
You must be signed in to change notification settings - Fork 217
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 in splita
/splitax
when field contains a single non-string value
#1589
Comments
As soon as I finished typing this I realised a possible solution and turns it out it worked: Apologies for the short-lived issue, feel free to close! |
Yes casting to
type-infers as
type-infers to
[Typo found 2024-08-25]: And, Maybe I've not been super-consistent with this TBH. On the one hand I never ever wanted Miller to be as loosey-goosey with string vs int as, say, JavaScript or PHP -- I always wanted On the other hand, I do some implicit type-casts -- the dot operator for example, since I felt there was nothing else meaningful for The |
The splita and splitax docs both say that they split a string into array, I think it could be fair to assume as a user that the argument would be converted to a string. I'm happy to take a stab and raise a PR for this in the next few days, if you'd like? |
Cool! Yes, happy to take a PR if you want! 😎 |
splita
/splitax
when field contains a single non-string value
I have a CSV that has a field
EAN
, this is either a single value:or a concatenated string of values:
When I split the field, it works when it's a case where there's multiple values, otherwise it ends up replacing the field with
(error)
. I'm converting this CSV to JSON, for what it's worth.The command I'm running is:
mlr --icsv --ojson --from products.csv put '$EAN = splita($EAN, "#")' then cut -f SKU,TITLE,LONG_DESC,EAN
Which outputs something like this (albeit longer):
I've only just come across miller, so I may be missing something obvious, I've tried with both
splita
andsplitax
. Any advice or is this not something I can work around?The text was updated successfully, but these errors were encountered: