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

Feature proposal: small auto inferencing edit #319

Closed
aborruso opened this issue Apr 3, 2020 · 1 comment
Closed

Feature proposal: small auto inferencing edit #319

aborruso opened this issue Apr 3, 2020 · 1 comment

Comments

@aborruso
Copy link
Contributor

aborruso commented Apr 3, 2020

Hi,
if I write

echo 'a=01,b=aaa,c=12.3' | mlr --ojson cat

I have { "a": 01, "b": "aaa", "c": 12.3 } and not { "a": "01", "b": "aaa", "c": 12.3 }. a is a string.

It's a zero padding problem.

What about to add in the auto inferencing process a regex control (if value =~ "^0[0-9]+") that maps correctly this very widespread kind of field value?

I know, I can use -S. And this is another example

echo 'a=00009,b=1.23456' | mlr  --opprint --barred put -S '$out1=$a;$out2=$b'

to have

+-------+---------+-------+---------+
| a     | b       | out1  | out2    |
+-------+---------+-------+---------+
| 00009 | 1.23456 | 00009 | 1.23456 |
+-------+---------+-------+---------+

But -S is global and if I run

echo 'a=00009,b=1.23456' | mlr  --opprint --barred put -S '$out1=$a;$out2=$b*3'

I have error

+-------+---------+-------+---------+
| a     | b       | out1  | out2    |
+-------+---------+-------+---------+
| 00009 | 1.23456 | 00009 | (error) |
+-------+---------+-------+---------+

Thank you

@johnkerl
Copy link
Owner

@aborruso I believe this is resolved by #756 / #788:

kerl@weryx[][miller]$ echo 'a=00009,b=1.23456' | mlr  --ojson put '$out1=$a;$out2=$b'
{
  "a": "00009",
  "b": 1.23456,
  "out1": "00009",
  "out2": 1.23456
}
kerl@weryx[][miller]$ echo 'a=00009,b=1.23456' | mlr --opprint --barred put '$out1=$a;$out2=$b'
+-------+---------+-------+---------+
| a     | b       | out1  | out2    |
+-------+---------+-------+---------+
| 00009 | 1.23456 | 00009 | 1.23456 |
+-------+---------+-------+---------+

If I'm mistaken please feel free to re-open -- thanks!

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