FME change data format from string to numeric - fme

Struggling with a really simple problem; I need to convert attribute from string to numeric in FME. have tried using the arithmetic editor, but every time I export to GIS I get string. It seems when one uses the statistics calculator you get numeric.
Any ideas? As I am all out of them.
Ashton

Related

Problem reading variables containing mix of numbers and strings

I am reading an Excel file (see syntax below) where some of the fields are text mixed with numbers. The problem is that SPSS reads some of these fields as numeric instead of string and then the text is deleted.
I assume this happens in cases where a large part of the first rows are empty or with a numeric value and then it defines the variable as numeric.
How can this be avoided?
GET DATA
/TYPE=XLSX
/FILE='M:\MyData.xlsx'
/SHEET=name 'Sheet1'
/CELLRANGE=FULL
/READNAMES=ON
/DATATYPEMIN PERCENTAGE=95.0
/HIDDEN IGNORE=YES.
When you use the get data command, the subcommand /DATATYPEMIN PERCENTAGE=95.0 tells SPSS that if up to 5% of the values in the field do not conform to the selected format it's still ok. So in order to avoid cases where only very few values are text and the field is read as number, you have to correct the subcommand to:
/DATATYPEMIN PERCENTAGE=100

What is this user input encoded as?

What encoding/encryption/manipulation would turn the following values from what you see on the left to what's on the right?
146.00 => 4046401A36E2EB1D
36.30 => 4042266666666666
76.22 => 40530E147AE147AE
3865.20 => 40DA06683E8C7FD4
0.200 => 3FC999999999999A
I am working with an XML file from a software application we use at work. I am trying to set up a tool that helps interpret and manipulate the XML files outside of the software, to allow work to be done while off of the limited licenses we have. In the software, users populate fields and can import/export XML files containing the info they have entered. When I open these XML files in a text editor, all the fields are clearly labeled as they would be in the program itself. The user input data is "encoded" however (hoping that's the accurate term), and it appears to be hexadecimal.
I have been able to take string and integer inputs and convert them back and forth to what's in the XML file, although the strings are backwards (the hex decodes to "w im 9" when the user input "9 mi w"). However anything the user enters as a decimal number is giving me trouble [edit: I determined the trouble is with fields that have associated units]. Some preliminary research has brought me to the idea of "attributes", but I don't know enough of XML to make use/sense of it. Below are two lines from the XML, the first one where the user data plays nice when trying to decode, and the second where something else is happening:
<BRIDGE_ID HEX="true">#31</BRIDGE_ID> Here the user just entered "1" for the Bridge ID
<LENGTH Units="23" HEX="true">#3FD381D7DBF487FD</LENGTH> Here the user entered "1" for length and the program forced it to 1.00 before exporting. This field is in feet.
I have discovered that the fields which assign units to the values are the ones that are not reversing nicely. Any field without units, i.e. no attributes in XML, works great in a simple web decoder. So the attributes complicate it somehow. In the first 5 examples at the top, the first value is in feet (Units="23"), while the second and third fields are both degrees (Units="52").
I know this is all over the place! Thank you anyone who can make sense of it and help me out!
For the 2nd, 3rd, and 5th values, the 16-digit hex string is simply the hex representation of the internal 64-bit double-precision IEEE floating point value whose decimal representation appears on the left.
That doesn't work for the 1st and 4th values, where the hex string is the representation of 44.50 and 26649.628817677338 respectively. Since you talk about units, perhaps there might be conversion from American units to metric involved?
This question has nothing to do with XML. Just because the data is wrapped in XML tags doesn't make it an XML question.

Convert text to number in Google Sheets

I'm reading currency values from a website and I'd like to do some calculations with these numbers. They come in this format:
$7,821.24
Here's an example file:
https://docs.google.com/spreadsheets/d/1vHEH_m16KXcDh7hY_BVG9lur1huFjWOnx5bWtgrdGdA/edit?usp=sharing
Now for some reason neither VALUE() and TO_PURE_NUMBER work for me (Can't parse to numberic value, telling me it's a text value).
My guess is that the comma and the $-sign confuse the formula, is there anything I can do to format this correctly? The dollar sign always appears in the values but the comma only appears separating thousands of values.
I just started using Sheets for this so I absolutely have no clue. Would really appreciate if someone could help me out.
Thanks for your time!
Issue:
It's a locale problem. The value coming from IMPORTXML is formatted as in United States locale, so your spreadsheet (which uses a different format) cannot convert it.
Solution #1. Changing locale:
If the spreadsheet locale is changed to United States or others with the same format (via selecting File > Spreadsheet settings and setting the mentioned locale), the retrieved value will be a number, and you can work with it without using any other formula.
Solution #2. Formula:
If changing the locale is not an option, one possible way to convert the value to a valid number in your locale is the following formula:
=SUBSTITUTE(SUBSTITUTE(RIGHT(A2;LEN(A2)-1);",";"");".";",")
Changing locale didn't work in my case. But I was able to split the number which google sheet isn't detecting as a real number. So split it with "," and "." and any currency sign you may have, and then combine individual values for desired output

Dart - Adding a recurring character to an integer

I'm working with long integers in dart and want to know how to add a comma after every three numbers.
Example;
999999999 would turn into 999,999,999
I get this information from an online API, so I can't change the int from a local file and follow that pattern, I need to intercept the int before/as it's being displayed.
Thanks
After looking at this stack question I found a way to accomplish this if your variable is a string.
This is what that looks like;
import 'package:intl/intl.dart';
final oCcy = new NumberFormat("#,##0.00", "en_US");
"${oCcy.format(yourVar)}",
Despite this, I was actually dealing with an integer, so using this method left me with an error. This was easily fixed by converting the string into an int.
This is what that looks like;
"${oCcy.format(double.parse(yourVar))}",

Character #\u009C cannot be represented in the character set CHARSET:CP1252 - how to fix it

As already pointed out in the topic, I got the following error:
Character #\u009C cannot be represented in the character set CHARSET:CP1252
trying to print out a string given back by drakma:http-request, as far as I understand the error-code the problem is that the windows-encoding (CP1252) does not support this character.
Therefore to be able to process it, I might/must convert the whole string.
My question is what package/library does support converting strings to certain character-sets efficiently?
An alike question is this one, but just ignoring the error would not help in my case.
Drakma already does the job of "converting strings": after all, when it reads from some random webserver, it just gets a stream of bytes. It then has to convert that to a lisp string. You probably want to bind *drakma-default-external-format* to something else, although I can't remember off-hand what the allowable values are. Maybe something like :utf-8?

Resources