Skip to main content
Solved

Format CSV into plain text with formatting in attachment - file "required"

  • January 25, 2023
  • 6 replies
  • 77 views

fmesafe.podpora
Contributor
Forum|alt.badge.img+11

Hi, Is there a transformer within FME that could format CSV into plain text with formatting, see the attachment? The original file can also be in another format, for example excel. If someone can think of another writer that will facilitate the solution of the problem, it can be.

file original - source data

file required - required data

 Thank you

Best answer by fmesafe.podpora

Hi. I got the solution. If anyone in the future is dealing with the same problem, I am posting the solution below.

Thank you all for your support

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

jkr_wrk
Influencer
Forum|alt.badge.img+35
  • January 25, 2023

It looks like a pretty complicated format.

 

You have to determine what the column width is to prepent the data with enough spaces, but also have to account for the character-width of your value to determine if you should write data though other column space.

 

Or are the first 10 lines a header that is pretty much fixed?

 

Then you could use https://www.safe.com/transformers/string-padder/ to fix all the column widths and the https://www.safe.com/transformers/string-concatenator/ to glue all the data together.

 

 


fmesafe.podpora
Contributor
Forum|alt.badge.img+11

It looks like a pretty complicated format.

 

You have to determine what the column width is to prepent the data with enough spaces, but also have to account for the character-width of your value to determine if you should write data though other column space.

 

Or are the first 10 lines a header that is pretty much fixed?

 

Then you could use https://www.safe.com/transformers/string-padder/ to fix all the column widths and the https://www.safe.com/transformers/string-concatenator/ to glue all the data together.

 

 

Hi. Thanks for the reply. I took another look at the source file and couldn't find any logic for individual columns to count characters. I am also attaching the points for viewing. I have to meet with the person who supplied me with the original data and ask. I was looking at setting up the stringPadder transformer, do you think it can be formatted with this? I think the setting is insufficient. Thank you


ebygomm
Influencer
Forum|alt.badge.img+46
  • Influencer
  • January 26, 2023

You would need to know the widths of each column to pad them to the right length before writing out

image


fmesafe.podpora
Contributor
Forum|alt.badge.img+11

You would need to know the widths of each column to pad them to the right length before writing out

image

Hi Ebygomm. Thank you for the response, on Monday I will try to meet with the person who gives me the data and I will let you know according to which logic the output should be defined. This is a civil aviation system. Thank you very much


fmesafe.podpora
Contributor
Forum|alt.badge.img+11

You would need to know the widths of each column to pad them to the right length before writing out

image

Hi. I found more detailed information. I need to have the above values written in the txt file. The main criterion is this separator "|" and column width doesn't matter. It should look like the highlighted part in the attachment. Ideally without the header Name, Airspace etc. Please how do I modify it to the required data with the separator "|" and achieve writing to a txt file? Thanks a lot


fmesafe.podpora
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • Best Answer
  • January 31, 2023

Hi. I got the solution. If anyone in the future is dealing with the same problem, I am posting the solution below.

Thank you all for your support