Question

Write to fixed width text file

  • 21 June 2021
  • 2 replies
  • 15 views

I use FME to get data from a database and have to write it to a text file with a fixed width. For example:

Streetname (24 characters) number (5 characters) City (24 characters) postal code (6 characters)

(+ like 25 more)

 

StreetA        00011    CITYAA      1111AB

StreetB        00021    CITYBA      1234AB

 

I have tried to use the format fuction in the attribute manager but only got the format back like : 10s24s5s6s

Input: @Format(24s,@Value(lokatie_straat))@Format(5s,@Value(lokatie_huisnummer))@Format(7s,@Value(lokatie_huisnummer_toevoeging))@Format(24s,@Value(lokatie_woonplaats))@Format(6s,@Value(lokatie_postcode))

 

How can I make a file with the above format? (I have no influence on the format used.)


2 replies

Userlevel 2
Badge +17

Hi @sisi_​ 

Try the @PadRight() (or @PadLeft()) functions. Based on the documentation, the @Format() function only works on numbers.

Hi @sisi_​ 

Try the @PadRight() (or @PadLeft()) functions. Based on the documentation, the @Format() function only works on numbers.

@debbiatsafe​ Thank you! It worked perfectly :)

Reply