csv_to_json(text) where the first line of text is a comma-separated header and following lines are rows: return the json.dumps of the list of dicts mapping headers to cell values (all values kept as strings). Empty trailing lines are ignored.csv_to_json('name,city\nAsha,Pune\nRaj,Delhi')[{"name": "Asha", "city": "Pune"}, {"name": "Raj", "city": "Delhi"}]Header keys pair with each row.
zip(headers, row_cells) builds each record.
dict(zip(...)) then dumps the list.