I have output from http request which is of string type but the data is like csv. As the output type in my request header is csv ('Accept':"application/csv"). As this the format supported by the source.But the response content type is a string.
res=request.content
type(res)` gives me string.
Here is the sample output from the object(res):
QueryTime
start,end
144488,144490
Data
Data - AData
id,G_id,name,type,time,sid,channel
23,-1,"B1",type1,144488,11,CH23
23,-1,"B1",type1,144488,11,CH23
Data - BData
id,G_id,time,se
23,-1,144488,undefined
23,-1,144488,undefined
If you see the data is in form of csv and there are multiple tables like you see "AData" & "BData" I am not getting which approach to take to read this. I have tried csv module but no help. I have tried dict.csv to convert but again same. Not getting desired output. May be I am doing something wrong as I am new with python. Need is to read each table from the output object.
with open('file.csv', 'wb') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',',quoting=csv.QUOTE_NONE)
spamwriter.writerow(rec)
with open('file.csv') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
print row
Experts please guide :-)