I have a mission to convert sqlite3 data to Json format and CSV format, I can read the data like this (line breaks added):
(2966,
u'http://buy.xineurope.com/thread-394248-1-1.html',
u'\u6d77\u666f\u623f\u627e\u4eba\u5408\u79df - \u623f\u5c4b\u4fe1\u606f - \u8df3\u86a4\u5e02\u573a - \u65b0\u6b27\u6d32-XinEurope-\u534e\u4eba\u4fe1\u606f\u5a31\u4e50\u4e92\u52a8\u95e8\u6237 - Powered by Discuz!',
1, 0, 12979085330693664L, 0, 0)
Is there some tools or modules (import json?) that help me to transfer, and the most import thing is what are the formats about json and CSV, could you give me a example use the data above?
Just like, I create a dict {‘a’:dad,’b’:dada}, but in json format?
To convert to
json, whether it’s one row orcursor.fetchall():or use
json.dump(some_file_object, data)if you want to store it to a file.To convert to
csv: