I am grappling with a basic CSV file (imported via JQuery's $.ajax
from the /data/league.csv
on the same website) containing three lines in this specific structure:
"Kimberlin Library","Queen's Building","Innovation Centre","etc etc"
8,2,0,-2
1,0,-1,0
My goal is to transform it into this format (using building
and percent
as data points for the x-y axes in Highcharts, while also populating a list with all three entries):
var leaguetable = {
building: ["Kimberlin Library","Queen's Building","Innovation Centre","etc etc"],
percent: [8,2,0,-2],
change: [1,0,-1,0]
};
It may seem like a trivial task, but I am struggling to find a solution despite attempting various techniques suggested by others (such as using split(/\r\n|\n|r/)
, exploring /^(.*)$/m
, and referencing resources like this question). I am willing to start fresh and require the simplest possible approach, whether through JQuery or pure Javascript. In a previous scenario, I resorted to converting the file to JSON, but I prefer to avoid that route this time if feasible.