Splunk Search

tostring commas and locale specific separators

colinj
Path Finder

My question is whether or not the tostring command is locale specific. If the locale specifies commas as the decimal and periods as the separator will tostring do the the right thing?

It might better if the option was tostring(, "separators").

arturo
Explorer

Where can I configure "commas" as "locale specific" ??

0 Karma

arturo
Explorer

My browser settings ? Just checked on both Safari (Mac OS X) and Chrome and nothing like that it's there ...

Any pointers ?

0 Karma

lguinn2
Legend

It's based on your browser settings.

0 Karma

lguinn2
Legend

Yes, it might be better. But the "commas" operator is locale specific.

[Update] I am wrong. After believing this for a long time, I was chagrined to find that it is untrue. The commas operator of the tostring command inserts commas. Always.

@sowings has a solution:

searchstring
| stats count
| eval count=tostring(count,"commas:)
| rex field=count mode=sed "s/,/./g"

bmunson_splunk
Splunk Employee
Splunk Employee

Actually that isn't complete. This would show 1234.56 as 1.234.56 when it is expected to see 1.234,56
Add an extra 2 lines to fix it.

| eval count=tostring(count,"commas")
| rex field=count mode=sed "s/\./#/g"
| rex field=count mode=sed "s/,/./g"
| rex field=count mode=sed "s/#/,/g"

make it into a macro if you need it a lot.

lguinn2
Legend

And my apologies for not coming back to this answer and fixing it sooner.

0 Karma

mplungjan
Path Finder
0 Karma

mplungjan
Path Finder

Does not seem to be in my Swiss German settings

0 Karma

colinj
Path Finder

So the "commas" operator will do the right thing?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...