Skip to main content

Hi,

I have a JSON file containing data for last 24 hours api information and want to convert it to excel2The time and api change accordingly depends on the time we browse to the JSON file. I would like to make the first list as the header but in the Attribute Manager we can't edit the Output attribute value. 4 

This is what I got once I used List Exploder and Attribute Manager.3Is there a way I can make the first row as the header?

 

One idea is to write your features as CSV and uncheck "write field names row". That way, you've magically(sort of) made your first row the header row. If you want to, you can do this as a featurewriter and then read it back up as a featurereader. But maybe it's good enough to write it to a CSV, since that can go to excel straight away.


Hi @aafirah​ 

There is a parameter in the Excel writer called "Use Attribute Names as Column Positions" that you can use to create 'dynamic' headers.

Assuming the structure of each JSON file is the same (a JSON object containing arrays with 26 elements), you should be able to fragment the JSON (no need to flatten) and use a JSONExtractor to extract each JSON array element into the corresponding letter of the alphabet (jsons0] as A, jsons1] as B, jsons2] as C, etc.).

In the Excel writer feature type dialog, set "Use Attribute Names as Column Positions" to Yes and "Output Field Names" as No.

JSONFirstRowAsHeaderI've attached an example workspace demonstrating this approach. I hope this helps!


One idea is to write your features as CSV and uncheck "write field names row". That way, you've magically(sort of) made your first row the header row. If you want to, you can do this as a featurewriter and then read it back up as a featurereader. But maybe it's good enough to write it to a CSV, since that can go to excel straight away.

Great! It works. Thanks for the idea :)


Hi @aafirah​ 

There is a parameter in the Excel writer called "Use Attribute Names as Column Positions" that you can use to create 'dynamic' headers.

Assuming the structure of each JSON file is the same (a JSON object containing arrays with 26 elements), you should be able to fragment the JSON (no need to flatten) and use a JSONExtractor to extract each JSON array element into the corresponding letter of the alphabet (jsons0] as A, jsons1] as B, jsons2] as C, etc.).

In the Excel writer feature type dialog, set "Use Attribute Names as Column Positions" to Yes and "Output Field Names" as No.

JSONFirstRowAsHeaderI've attached an example workspace demonstrating this approach. I hope this helps!

Hi @debbiatsafe​ 

Thank you so much! This idea works too.. glad that you're willing to help me.

I have one more question, is there also any parameter in ESRI Shapefile writer to make the first row as the header?


Hi @debbiatsafe​ 

Thank you so much! This idea works too.. glad that you're willing to help me.

I have one more question, is there also any parameter in ESRI Shapefile writer to make the first row as the header?

Hi @aafirah​ 

Unfortunately, the Shapefile writer does not have a similar parameter.

If you wish to write directly to Shapefile, you would have to use a dynamic schema. If you are OK with writing to an intermediate format like Excel or CSV before writing to Shapefile, then you should use @fhilding​ 's FeatureReader suggestion.


Hi @debbiatsafe​ 

Thank you so much! This idea works too.. glad that you're willing to help me.

I have one more question, is there also any parameter in ESRI Shapefile writer to make the first row as the header?

Hi @debbiatsafe​ 

Okay, I understand. Thank you for the feedback :)


Reply