span8
span4
早上好,
How could I transform a number into French Notation?
Ex: 1000000.00 into 1 000 000,00
This information represents surface area on a map.I have already worked out the calculations and the placement transformers and am stuck on the customer's desired presentation.
Thank you,
Chris
Hi@ccomeau,a PythonCaller with this script might help you.
# PythonCaller Script Example: Format a numeric value in French Notation# Assuming that the feature has an attribute called "value" storing a numeric value.# Format the numeric value using comma as thousands separator,# replace commas with spaces,and then replace the decimal point with a comma.def processFeature(feature): attr = 'value' v = float(feature.getAttribute(attr)) s = '{0:,.2f}'.format(v).replace(',',' ').replace('.',',') feature.setAttribute(attr,s)
import localeclass FeatureProcessor(object): def __init__(self): locale.setlocale(locale.LC_NUMERIC,'French') def input(self,feature): attr = 'value' v = float(feature.getAttribute(attr)) feature.setAttribute(attr,locale.format_string('%.2f',V,True)) self.pyoutput(feature)However,the result is shown like this in my environment - Japanese Windows.
1?000?000,00I'm curious how the script works in an European locale.
早上好,
Thank you both for the quick replies.Your FMWs reminded me that I need to update my licence from 2015.1.0.3 as some transformers are not available.
@itay,the FMW you posted works well with millions but smaller and larger numbers do not format correcly.前任。235 came out as 2 35.I would need to split from the right.Perhaps flipping the number around then splitting if,然后翻动列表就可以了。
@高桥,I had not thought of using Python.Interesting solution option.Sadly,I am a novice programmer and can't get your first solution working.That being said,your second option using the local settings was a novel solution that did work.
© 2019 亚搏在线Safe Software Inc |Legal