The stupid question is the question not asked | |
PerlMonks |
Spreadsheet::ReadSXC and localization -- Google Sheets vs LibreOffice Calcby vitoco (Hermit) |
on Jan 11, 2020 at 15:27 UTC ( [id://11111329]=perlquestion: print w/replies, xml ) | Need Help?? |
vitoco has asked for the wisdom of the Perl Monks concerning the following question: Hi! I wrote a script that creates JSON files based on the contents of Google Sheets using Spreadsheet::Read and Spreadsheet::ReadSXC, which are previously downloaded into local files using HTTP::Tiny. All works nice, even when the localization of the Google Sheet is different than US in the formatting of numbers: in my case, comma is for decimals and period is for thousand separator. But something wents wrong when I opened one of the downloaded ODS files with LibreOffice, edited some of the values and saved it again before procesing it with my script. The modified ODS file now gives floats with my localization standard!!! If I open again the ODS, I can see the values in my local format. To check what is going on, I extracted the "content.xml" from both original and modified ODS files and compared a cell content. This is what I found: Integer value (in a float cell): - Google Sheet
- LibreOffice Calc
Float value: - Google Sheet
- LibreOffice Calc
As in the JSON file I must write numbers without the thousand separator, with ODS files just downloaded from Sheets, I had to remove the commas with a regexp, but in the ODS file that was modified by Calc, the regexp removes the decimal separator and multiplies the value x100!!! So, it seems that cell and cellrow methods retrieves the value from the "text:p" tag instead of the "office:value" property of the "table:tablecel" tag. Format parsing in these methods seems to work only for dates and strings, but not for numeric values, . Is there a way to process cell values in a "neutral" region, i.e. without localization?
Back to
Seekers of Perl Wisdom
|
|