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.
I'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.
I'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 :)