xlrd+excel determine decimal separator

P

peter

Hi experts,

i want to ask you if somebody knows how can I determine, with a help
of xlrd, what kind of decimal separator (. or ,) does the user have.

Thx in advance.
Rg,
Peter
 
J

John Machin

i want to ask you if somebody knows how can I determine, with a help
of xlrd, what kind of decimal separator (. or ,) does the user have.

It's nothing to do with xlrd. It reads files and gives you the numbers
as Python floats. Note that a user of locale A (uses '.') can save an
Excel file and send it to a user of locale B (uses ',') and the
receiver will see ',' -- as you might expect, locale-specific info is
not kept in the file. If you want to find out the current user's
decimal separator (and other useful info), use the locale module.

Here's what I get after I change my regional settings on Windows XP to
French/France:

Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information. {'mon_decimal_point': ',', 'int_frac_digits': 2, 'p_sep_by_space':
1, 'frac_digits': 2, 'thousands_sep': '\xa0', 'n_sign_posn': 1,
'decimal_point': ',', 'int_curr_symbol': 'EUR', 'n_cs_precedes': 0,
'p_sign_posn': 1, 'mon_thousands_sep': '\xa0', 'negative_sign': '-',
'currency_symbol': '\x80', 'n_sep_by_space': 1, 'mon_grouping': [3,
0], 'p_cs_precedes': 0, 'positive_sign': '', 'grouping': [3, 0]}

Note: there are two different decimal separators.

After switching it back to normal and re-starting Python:
{'mon_decimal_point': '.', 'int_frac_digits': 2, 'p_sep_by_space': 0,
'frac_digits': 2, 'thousands_sep': ',', 'n_sign_posn': 3,
'decimal_point': '.', 'int_curr_symbol': 'AUD', 'n_cs_precedes': 1,
'p_sign_posn': 3, 'mon_thousands_sep': ',',
'negative_sign': '-', 'currency_symbol': '$', 'n_sep_by_space': 0,
'mon_grouping': [3, 0], 'p_cs_precedes': 1, 'positive_sign': '',
'grouping': [3, 0]}

HTH,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top