I've got an input array in this format:
[[timestamp, jobid, time to completion],[..]]
the data is from a SQL DB, grouped by both timestamp, and jobid, so the array looks like:
[
[1, 30, 400],
[1, 31, 200],
[2, 29, 300],
..
]
I would like to create a new array with one column for every jobid, instead of one row with every job id, that is, a single row per timestamp.
So, I wrote some code that iterated through the above array, and populated a new array, simple enough, except, the result array isn't fixed width, that is, the result looks like:
[
[1, 400, 200],
[2, 300]
..
]
Which makes it impossible for me to say that values from [1] are job ID 30, so I can't have a meaningful header row. What I would like is, data in this format:
timestamp, jobid29, jobid30, jobid31
[
[1, 0, 400, 200],
[2, 300, 0, 0],
..
]
I can't output a map, unfortunately.
How can I achieve this? I know I'll haveto go through the input once to get all the distinct jobids, and then I guess I'd map each jobid to a position, etc, I'm wondering if this is the best way?
Thank you.