csv to json in python
<p>Hey so I have some hash ids in a csv file like</p>

<p>XbRPhe65YbC+xtgGQ8ukeZEr9xFOC4MEs9Z0wUidGSec=
XbRPhe65YbC+xtgGQ8uksrqSUJ/HhTPj1d2pL0/vuGrHM=</p>

<p>and I want to parse them into python wrap them in some additional code like </p>

<p>{"id" :"XbRPshe65YbC+xtGQ8ukqR2u2btfNeNe2gtcs72QbxPA=", "timestamp":"20150831"}, </p>

<p>and then wrap all of that in some JSON syntax. This is then sent as a post request. Problem is I cannot seem to make it JSON readable. Everything seems to be ordered wrong and I am getting extra \. </p>

<pre><code>import os
import pandas as pd
from pprint import pprint

df=pd.read_csv('test.csv',sep=',',header=None)
df[0] = '{"id" :"' + df[0].astype(str) + '", "timestamp":"20150831"}, ' 

df = df[:-1] # removes last comma


test = 'hello'
data =[ { "ids":[ df[0]],
          "attributes":[
                {
                "name":"girl"
                },
                {
                "name":"size"
                }
                ]
        }
        ]

json1 = data.to_json()
print(json1)
</code></pre>