3

I am trying to create a JSON file from multiple CSV files. The files would be named like bugs.csv and executions.csv.

Example of the bugs.csv files:

month,,1,2,3,4
app1,ownerA,42,34,38,12
app2,ownerA,13,23,24,43
app3,ownerB,48,72,39,62

Example of the executions.csv files:

month,,1,2,3,4
app1,ownerA,1200,1500,900,1000
app2,ownerA,600,650,660,540
app3,ownerB,2750,3500,3000,3200

What I would like the JSON to look like:

[{"Application":"app1",
"Owner":"ownerA",
"bugs":[[1,42],[2,34],[3,38],[4,12]],
"executions":[[1,1200],[2,1500],[3,900],[4,1000]]},

{"Application":"app2":,
"Owner":"ownerA",
"bugs": [[1,13],[2,23],[3,24],[4,43]],
"executions":[[1,600],[2,650],[3,660],[4,540]]}]
6
  • 1
    a python script using the csv and json modules could do this for you in a few lines. or you may get lucky and someone more karma-hungry will write it for you. Commented Oct 24, 2012 at 2:04
  • Thanks philo. Does anyone one else have suggestions using javascript? All of the rest of the work is in javascript and our service provider doesn't have python devs. Commented Oct 25, 2012 at 12:28
  • you can also use OpenRefine with a custom JSON export. However OpenRefine doesn't support automation. It will good for a one time job only. Commented Nov 13, 2012 at 17:06
  • You can refer this stackoverflow.com/questions/15332450/… Commented Mar 12, 2013 at 5:35
  • Thanks magdmartin, that did the trick. Commented Mar 25, 2013 at 13:44

1 Answer 1

0

I used OpenRefine, once you create a project, it let me convert excel files one one layout to the desired JSON layout without needing to re-code each time. It's a bit manual, but I only do this once a month, so 2-3 minutes doesn't kill me.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.