I collect data from a website, using the pycurl functions. Following the example code, after slight modifications I do get all the data in one big buffer. It comes in a format of { "field_id":"data","field_id2":"data2", .. } I wish to parse this into lines of text, similar to csv, with one line of output for each set of data enclosed by curly braces. How best to achieve this, as "pythonic" as can be? Oh, and where can I best do the UTF-8 conversion? I suspect the source coding to be ISO8859 - but that is a secondary matter.
Relevant code:
buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, MY_URL)
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()
Sample data:
`{"status":"ok","nature":"Liste des champs principaux de tous les terrains publi\u00e9s","count":"1211","liste":
[{"id":"3667","date_modif":"2013-04-03 11:27:00","code_terrain":"LF5155","toponyme":"Champagne Vol Libre","type_terrain":"Base ULM Autorisation OBLIGATOIRE ","latitude":"N 48 56 10","longitude":"E 004 03 42","altitude":"335` ft","pays":"France","region":"Grand-Est","departement":"Marne","ville":"Villeneuve"},
{"id":"5118","date_modif":"2015-08-18 13:17:23","code_terrain":"LF4861","toponyme":"La Canourgue Conques","type_terrain":"A\u00e9rodrome ferm\u00e9.","latitude":"N 44 24 55","longitude":"E 003 17 05","altitude":"2920 ft","pays":"France","region":"Occitanie","departement":"Loz\u00e8re","ville":"La Canourgue"}