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

Bug when replacing a dot #1310

Closed
badrelmers opened this issue Jun 7, 2023 · 4 comments
Closed

Bug when replacing a dot #1310

badrelmers opened this issue Jun 7, 2023 · 4 comments
Assignees

Comments

@badrelmers
Copy link

I have this csv:

a,b,c
1,1.2,3

when I run this from a batch file

mlr --csvlite  --from test.csv put '$b=ssub($b,".","0")'

I get

a,b,c
1,(error),3

I should get: 1,102,3

I read the doc , I searched the old issues and searched google, but I could not find the solution, so maybe this is a bug? or am I doing something wrong?

this was with the last miller version miller-6.8.0-windows-386 on windows 7 x64 using cmd

thank you

@johnkerl johnkerl changed the title bug when replacing a dot in windows version bug when replacing a dot Jun 7, 2023
@johnkerl
Copy link
Owner

johnkerl commented Jun 7, 2023

@badrelmers I can reproduce; this isn't Windows-specific

The problem is that $b is a float, not a string.

So, three things:

  • You can do mlr --csvlite --from test.csv put '$b=ssub(string($b),".","0")'
  • The (error) doesn't give you much to go on -- it doesn't say that ssub can't handle non-strings -- this is tracked on Fail fast and print error to console #1106
  • Also, ssub should (like some other functions) do the conversion to string for you

@johnkerl johnkerl self-assigned this Jun 7, 2023
@johnkerl johnkerl changed the title bug when replacing a dot Bug when replacing a dot Jun 7, 2023
@aborruso
Copy link
Contributor

aborruso commented Jun 7, 2023

@badrelmers you could force all to string using -S

mlr --csvlite -S  --from input.csv put '$b=ssub($b,".","0")'

@badrelmers
Copy link
Author

oh! , the -S or string($b) solve it. miller rocks

thank you very very much @johnkerl @aborruso

@johnkerl
Copy link
Owner

johnkerl commented Jun 7, 2023

Leaving this open so I can do the third bullet above ☝️

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

No branches or pull requests

3 participants