ParseBuddy is a simple parsing tool that can parse CSV to JSON and JSON to CSV. Function csvToJson() takes in CSV data as a string and returns a JSON object. Function jsonToCsv() takes in JSON object and returns a CSV string. This was made during a coding challenge, a part of which which required to parse and display statistical data provided in CSV format. "Why re-invent the wheel?" Yeah sure, I could have had used a ready made library, but I was learning JS, and wanted to build everything myself. Feel free to use it and improve it! Currently, it is capable of handling only small size of data, but I am working on making it able to parse files in the size of gigabytes.

I want to

Parse CSV to JSON

Sample Input:

batting_score,runs_conceded,opposition,ground,date,match_result
21,3,Australia,Adelaide,15 Dec 1991,lost
77,27,West Indies,Brisbane,11 Jan 1992,won

Output:

{
  "message": "No errors found",
  "linesFound": 2,
  "linesParsed": 2,
  "data": [
    {
      "batting_score": 21,
      "runs_conceded": 3,
      "opposition": "Australia",
      "ground": "Adelaide",
      "date": "15 Dec 1991",
      "match_result": "lost"
    },
    //other values
  ]
}

Parse JSON to CSV

Sample Input:

[
	{a: 1, b: 2, c: 3, d:4},
	{a: 11, b: 22, c: 33, d:44},
	{a: 111, b: 222, c: 333, d:444}
]

Output:

a,b,c,d
1,2,3,4
11,22,33,44
111,222,333,444