If I read your question correctly I think I could summarise it by saying that you have the data in a JSON format, but you want to use it in a csv format.

If this is correct, you could approach the problem in a slightly different way and have your data file external to the main script and then when you read the data in you could use d3.json or d3.csv depending on the format. The example here uses an external csv file.

EDIT: Here is an example on using your code and an external csv file

Related Query

More Query from same tag