How to get json from csv file in row wise using flask
To return json in your desired format you can use the built in dataframe method instead of listing and jsonifying:
df.to_json(orient="records")
This will give you a json encoded string as in the example below:
df = pd.DataFrame([[5, 'Sanjeev', 'AE'], [6, 'Sven', 'AA']], columns = ["id", "name", "2"])
Which returns:
id name 20 5 Sanjeev AE1 6 Sven AA
And then as JSON:
df.to_json(orient="records")'[{"id":5,"name":"Sanjeev","2":"AE"},{"id":6,"name":"Sven","2":"AA"}]'