Skip to main content
Solved

How to extract list in JSON to Excel file

  • February 17, 2021
  • 2 replies
  • 50 views

Hi,

I have extracted the list in JSON file to an excel file using ListExploder. However the result didn't come out as expected:result 

Any suggestions on which transformer can I use to get the expected result as attached:

Expected 

Thank you in advance.

Best answer by caracadrian

Use ListElementCounter to get the total number of elements, ListExploder to separate into features.

Use AttributeManager to create 4 new attributes (your list appears to have 4 columns) with conditional values: if 

@fmod(@Value(_element_index),4)=0

 than give the first attribute the value of station_info_apims, =1 the second, =2 the third and =3 the fourth.

Than create a fifth attribute that will become the new index with the value:

(@Value(list_count)-@Value(_element_index))/4+@fmod(@Value(_element_index),4)/4

And just use an Aggregator with GroupBy your fifth attribute Mode set to Attributes Only and Accumulation Mode set to Merge Incoming Attributes.

I attached a sample workspace.

 

View original
Did this help you find an answer to your question?

2 replies

caracadrian
Contributor
Forum|alt.badge.img+23
  • Contributor
  • Best Answer
  • February 17, 2021

Use ListElementCounter to get the total number of elements, ListExploder to separate into features.

Use AttributeManager to create 4 new attributes (your list appears to have 4 columns) with conditional values: if 

@fmod(@Value(_element_index),4)=0

 than give the first attribute the value of station_info_apims, =1 the second, =2 the third and =3 the fourth.

Than create a fifth attribute that will become the new index with the value:

(@Value(list_count)-@Value(_element_index))/4+@fmod(@Value(_element_index),4)/4

And just use an Aggregator with GroupBy your fifth attribute Mode set to Attributes Only and Accumulation Mode set to Merge Incoming Attributes.

I attached a sample workspace.

 


  • Author
  • February 17, 2021
caracadrian wrote:

Use ListElementCounter to get the total number of elements, ListExploder to separate into features.

Use AttributeManager to create 4 new attributes (your list appears to have 4 columns) with conditional values: if 

@fmod(@Value(_element_index),4)=0

 than give the first attribute the value of station_info_apims, =1 the second, =2 the third and =3 the fourth.

Than create a fifth attribute that will become the new index with the value:

(@Value(list_count)-@Value(_element_index))/4+@fmod(@Value(_element_index),4)/4

And just use an Aggregator with GroupBy your fifth attribute Mode set to Attributes Only and Accumulation Mode set to Merge Incoming Attributes.

I attached a sample workspace.

 

Thank you so much for your answer! I'm new to this FME and your answer really helps me. I will try your solution to resolve this issue.

 

Thanks again!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings