Thousands Separator

Post about your cool new gadgets and toys. Ask other users for help with techy problems.

Thousands Separator

Postby Мастер » Tue Jul 08, 2014 1:17 am

Maybe this one is for Llance, since he's a Windows guy . . .

I am creating some graphs using software called "gnuplot", which is described here. This software uses syntax which is similar to C language for printing, e.g., "%4.2f" to print floating-point numbers. But it uses some sort of system library to do this, because the result is different on different systems.

To get it to print the number "one million" as "1,000,000" instead of "1000000", I can put "%'1.0f", and also issue a command set decimalpoint locale "en_GB.UTF-8". This works perfectly on a Mac, recent versions of OS X. But it doesn't work on Windows, which apparently doesn't support this capability by default.

Any way to fix this?

As a side note, the result of changing the locale to "de_DE.UTF-8" are truly disturbing, and not what I would have expected at all, but I'll leave that one for another day.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23929
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Thousands Separator

Postby Lance » Tue Jul 08, 2014 3:14 am

In the Windows Control Panel there is a section for Region and Language settings. This is where you would set stuff like that.
No trees were killed in the posting of this message.
However, a large number of electrons were terribly inconvenienced.

==========================================

Build a man a fire and he will be warm for a few hours.
Set a man on fire and he will be warm for the rest of his life.
User avatar
Lance
Administrator
Administrator
Cheeseburger Swilling Lard-Ass who needs to put down the remote and get off the couch.
 
Posts: 91394
Joined: Thu May 12, 2005 5:51 pm
Location: Oswego, IL

Re: Thousands Separator

Postby Мастер » Tue Jul 08, 2014 5:04 am

Lance wrote:In the Windows Control Panel there is a section for Region and Language settings. This is where you would set stuff like that.


This seems to affect the user interface, but it doesn't seem to have any effect on the software libraries called by software like this.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23929
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Thousands Separator

Postby Lance » Tue Jul 08, 2014 6:05 am

Sounds like it must be a parameter of the library then. You're outside my skillset.
No trees were killed in the posting of this message.
However, a large number of electrons were terribly inconvenienced.

==========================================

Build a man a fire and he will be warm for a few hours.
Set a man on fire and he will be warm for the rest of his life.
User avatar
Lance
Administrator
Administrator
Cheeseburger Swilling Lard-Ass who needs to put down the remote and get off the couch.
 
Posts: 91394
Joined: Thu May 12, 2005 5:51 pm
Location: Oswego, IL

Re: Thousands Separator

Postby Мастер » Tue Jul 08, 2014 6:24 am

Lance wrote:Sounds like it must be a parameter of the library then. You're outside my skillset.


I think it is, but I don't know how to set it.

Here is the beginning of a script which works on Mac OS X.

Code: Select all
reset
set terminal pdfcairo enhanced color dashed
set output "Rubbish.pdf"
set decimalsign locale "en_GB.UTF-8"
set border 31 lt -1 lw 1
set key bottom right
set xrange [3:7]
set yrange [0:200000.0]
set xtics nomirror 1.0 font "Helvetica,9"
set ytics nomirror 0.0,10000.0 font "Helvetica,9"
set format x "%1.0f%%"
set format y "$%'1.0f"


This is (the beginning of) a script which is compiled to produce a PDF file, containing a graph. The critical line is the last one, which includes a quote mark in the C format string. But including the locale statement near the beginning is also necessary - I don't get the commas without it.

But the result of compiling this on a Windows machine is that the numbers don't get the thousands separator, whereas under Mac OS X, they do.

So I don't know whether a) there is no way to do this under Windows, or b) there is a way, which is different than the Mac OS X way. Haven't been able to find anything at U. Google.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23929
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Thousands Separator

Postby tubeswell » Tue Jul 08, 2014 6:46 am

wow
A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.

If you are seeing an apparent paradox, that means you are missing something.
User avatar
tubeswell
Enlightened One
Enlightened One
 
Posts: 324861
Joined: Sun Sep 19, 2010 11:51 am
Location: 129th in-line to the Llama Throne (after the last purge)

Re: Thousands Separator

Postby MM_Dandy » Tue Jul 08, 2014 3:06 pm

Мастер wrote:
Lance wrote:Sounds like it must be a parameter of the library then. You're outside my skillset.


I think it is, but I don't know how to set it.

Here is the beginning of a script which works on Mac OS X.

Code: Select all
reset
set terminal pdfcairo enhanced color dashed
set output "Rubbish.pdf"
set decimalsign locale "en_GB.UTF-8"
set border 31 lt -1 lw 1
set key bottom right
set xrange [3:7]
set yrange [0:200000.0]
set xtics nomirror 1.0 font "Helvetica,9"
set ytics nomirror 0.0,10000.0 font "Helvetica,9"
set format x "%1.0f%%"
set format y "$%'1.0f"


This is (the beginning of) a script which is compiled to produce a PDF file, containing a graph. The critical line is the last one, which includes a quote mark in the C format string. But including the locale statement near the beginning is also necessary - I don't get the commas without it.

But the result of compiling this on a Windows machine is that the numbers don't get the thousands separator, whereas under Mac OS X, they do.

So I don't know whether a) there is no way to do this under Windows, or b) there is a way, which is different than the Mac OS X way. Haven't been able to find anything at U. Google.


I found some chatter about using various identifiers to get the used locale to map properly to a locale supported by the Windows OS - but none of that seemed to actually resolve the thousands separator issue. MSDN on the setlocale method. MSDN of supposedly supported Country/Region strings.

Is it possible to include third party libraries? If so, you might be able to use the GetNumberFormat function.
User avatar
MM_Dandy
Moderator
Moderator
King of Obscurity
 
Posts: 4927
Joined: Thu May 12, 2005 9:02 pm
Location: Canton, SD, USA

Re: Thousands Separator

Postby Мастер » Tue Jul 08, 2014 3:10 pm

MM_Dandy wrote:I found some chatter about using various identifiers to get the used locale to map properly to a locale supported by the Windows OS - but none of that seemed to actually resolve the thousands separator issue. MSDN on the setlocale method. MSDN of supposedly supported Country/Region strings.

Is it possible to include third party libraries? If so, you might be able to use the [url=http://msdn.microsoft.com/en-us/library/windows/desktop/dd318110(v=vs.85).aspx]GetNumberFormat function[/ur].


I don't know whether it is possible, but it's worth a try.

The simple work around is, compile the script on a Mac. But a) I am working with other people, who may not have Macs, so that would make me the designated compiler, and b) I prefer whenever possible not to make my software computer/system specific.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23929
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Thousands Separator

Postby Lance » Tue Jul 08, 2014 4:29 pm

Does this help: Commas in gnuplot labels
No trees were killed in the posting of this message.
However, a large number of electrons were terribly inconvenienced.

==========================================

Build a man a fire and he will be warm for a few hours.
Set a man on fire and he will be warm for the rest of his life.
User avatar
Lance
Administrator
Administrator
Cheeseburger Swilling Lard-Ass who needs to put down the remote and get off the couch.
 
Posts: 91394
Joined: Thu May 12, 2005 5:51 pm
Location: Oswego, IL

Re: Thousands Separator

Postby Мастер » Tue Jul 08, 2014 8:57 pm

Lance wrote:Does this help: Commas in gnuplot labels


I found that one. The solution specified is what I am using on Mac. It also allegedly works on Linux. Just not Windows :)
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23929
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Thousands Separator

Postby Lance » Wed Jul 09, 2014 12:27 am

Hmm, okay.

Have you seen this one?
No trees were killed in the posting of this message.
However, a large number of electrons were terribly inconvenienced.

==========================================

Build a man a fire and he will be warm for a few hours.
Set a man on fire and he will be warm for the rest of his life.
User avatar
Lance
Administrator
Administrator
Cheeseburger Swilling Lard-Ass who needs to put down the remote and get off the couch.
 
Posts: 91394
Joined: Thu May 12, 2005 5:51 pm
Location: Oswego, IL

Re: Thousands Separator

Postby Мастер » Wed Jul 09, 2014 12:32 am

Lance wrote:Hmm, okay.

Have you seen this one?


Hmm. Most of the posts here say it isn't going to work in Windows, but then the last one suggests it should. I'll have to look into it.

The solution proposed earlier on does not work (at least for me) on Mac, but a slight modification does it.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23929
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Thousands Separator

Postby Lance » Wed Jul 09, 2014 12:42 am

Hey, here's another. Look toward the bottom.

http://stackoverflow.com/questions/2232 ... t-grouping
No trees were killed in the posting of this message.
However, a large number of electrons were terribly inconvenienced.

==========================================

Build a man a fire and he will be warm for a few hours.
Set a man on fire and he will be warm for the rest of his life.
User avatar
Lance
Administrator
Administrator
Cheeseburger Swilling Lard-Ass who needs to put down the remote and get off the couch.
 
Posts: 91394
Joined: Thu May 12, 2005 5:51 pm
Location: Oswego, IL

Re: Thousands Separator

Postby Lance » Wed Jul 09, 2014 12:43 am

If this is something you'll need often you could install a Linux virtual machine on your Windows PC. Virtual Box is great and free.
No trees were killed in the posting of this message.
However, a large number of electrons were terribly inconvenienced.

==========================================

Build a man a fire and he will be warm for a few hours.
Set a man on fire and he will be warm for the rest of his life.
User avatar
Lance
Administrator
Administrator
Cheeseburger Swilling Lard-Ass who needs to put down the remote and get off the couch.
 
Posts: 91394
Joined: Thu May 12, 2005 5:51 pm
Location: Oswego, IL

Re: Thousands Separator

Postby Мастер » Wed Jul 09, 2014 1:35 am

Lance wrote:If this is something you'll need often you could install a Linux virtual machine on your Windows PC. Virtual Box is great and free.


I can currently do this on a Mac no problem. Ideally, the scripts would be portable, so I could give them to other people, have them plug in their own data (so keep the format, etc., just change the data), and compile the script to produce a graph. So it's really they who would have to do things like put a virtual machine in, if that's what it takes. Or just live without the thousands separator. My scripts (as they are written now) do compile, they just don't produce the thousands separator when compiled on a Windows machine.
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23929
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Thousands Separator

Postby Lance » Wed Jul 09, 2014 4:31 am

I think you missed this. It gives a work-around near the end of the page.

Lance wrote:Hey, here's another. Look toward the bottom.

http://stackoverflow.com/questions/2232 ... t-grouping
No trees were killed in the posting of this message.
However, a large number of electrons were terribly inconvenienced.

==========================================

Build a man a fire and he will be warm for a few hours.
Set a man on fire and he will be warm for the rest of his life.
User avatar
Lance
Administrator
Administrator
Cheeseburger Swilling Lard-Ass who needs to put down the remote and get off the couch.
 
Posts: 91394
Joined: Thu May 12, 2005 5:51 pm
Location: Oswego, IL

Re: Thousands Separator

Postby Мастер » Wed Jul 09, 2014 4:58 am

Lance wrote:I think you missed this. It gives a work-around near the end of the page.


You mean the very last one? I've done that :) The issue is (apart from it being something of a pain), there can't be any automatic scaling.

As a last resort, it could be used. It's just such a kludge :oops:
They call me Mr Celsius!
User avatar
Мастер
Moderator
Moderator
Злой Мудак
Mauerspecht
 
Posts: 23929
Joined: Tue Aug 02, 2005 2:56 pm
Location: Far from Damascus

Re: Thousands Separator

Postby Lance » Wed Jul 09, 2014 2:54 pm

Yeah, that might be your only choice. It looks like they don't even care about fixing it...
No trees were killed in the posting of this message.
However, a large number of electrons were terribly inconvenienced.

==========================================

Build a man a fire and he will be warm for a few hours.
Set a man on fire and he will be warm for the rest of his life.
User avatar
Lance
Administrator
Administrator
Cheeseburger Swilling Lard-Ass who needs to put down the remote and get off the couch.
 
Posts: 91394
Joined: Thu May 12, 2005 5:51 pm
Location: Oswego, IL


Return to Computers and Gadgets

Who is online

Users browsing this forum: No registered users and 1 guest