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
Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...