Solved

How to extract list in JSON to Excel file

  • 17 February 2021
  • 2 replies
  • 13 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.

icon

Best answer by caracadrian 17 February 2021, 07:46

View original

2 replies

Badge +20

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.

 

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!

Reply