Support Questions

Find answers, ask questions, and share your expertise

how to convert json blueprint file to csv file

avatar

Hi all

How to convert blueprint json file to csv file?

My target is to convert all properties parameters to a csv file from the amabri cluster

Example – generate blueprint json file from my ambari cluster

curl -u admin:admin -H "X-Requested-By: ambari" -X GET http://10.23.4.122:8080/api/v1/clusters/HDP26?format=blueprint -o /tmp/HDP01_blueprint.json

example of expected results: ( all parameters from all config types should be in the csv file )

autopurge.purgeInterval,512

dataDir,/hadoop/zookeeper

autopurge.snapRetainCount,10

clientPort,2181

initLimit,11

tickTime,2000

syncLimit,5

Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Rising Star

@uri ben-ari

You can probably use a tool like jq to achieve this through a shell script:

https://stedolan.github.io/jq/

As to how to use jq, there is available literature on forums such as stackoverflow:

https://stackoverflow.com/questions/1955505/parsing-json-with-unix-tools

View solution in original post

4 REPLIES 4

avatar
Super Collaborator

What is your purpose in converting the JSON to a CSV? Perhaps we can find a better solution for you depending on what you're trying to accomplish.

avatar
Rising Star

@uri ben-ari

You can probably use a tool like jq to achieve this through a shell script:

https://stedolan.github.io/jq/

As to how to use jq, there is available literature on forums such as stackoverflow:

https://stackoverflow.com/questions/1955505/parsing-json-with-unix-tools

avatar

yes , all I need is to know what is the config type for parameter ( so in the json file we have parameters ) but what I need to know by API is the config type for the parameter please help if you can

Michael-Bronson

avatar
Super Collaborator

Could you give me an example?

It sounds like you just want to be able to read the values for a property inside of the JSON file - could you explain why specifically you need it in a CSV format? For nested data like this it is usually better to have it in a JSON format.