Skip to main content

What is the best management practice for setting attribute data types prior to writers, preferably at the reader?

 

My specific issue de jour is an attribute (data e.g. 1023, 1034, 1002.1) that is reading in as real32 but indeed they need to be strings for my use case. A custom python transformer (type casting to strings) changes the values to strings '1023.0', '1034.0', '1002.1', due to real32 initial type, which won't work. I need strings '1023', '1034', '1002.1'.

 

Thanks for reading and any response is appreciated.

 

Tyler

FME Desktop 2020.2

Internally FME doesn't really enforce strict data types (but specific readers and writers will). You could probably get away with using a StringReplacer to replace the regex \\.0$ with an empty string.


Internally FME doesn't really enforce strict data types (but specific readers and writers will). You could probably get away with using a StringReplacer to replace the regex \\.0$ with an empty string.

@Hans van der Maarel​ , That's a bit dangerous because if I have an original value of 1000.0 it will be modified to '1000' instead of the desired '1000.0'.

 

BTW: My reader in this case is the csv reader. You mentioned some readers allow type setting. Which ones? Thank you.

 

Tyler


@Hans van der Maarel​ , That's a bit dangerous because if I have an original value of 1000.0 it will be modified to '1000' instead of the desired '1000.0'.

 

BTW: My reader in this case is the csv reader. You mentioned some readers allow type setting. Which ones? Thank you.

 

Tyler

My mistake, I misread your original question.


Does the string formatter not work for this use case?


Does the string formatter not work for this use case?

Yep. That did it. Just used 's' as format string. Good to go. Thank you. Tyler


Reply