Right Format to Embed JSON in CSV
Question: I am trying to write a Python function that query an API that returns various
JSON snippets and want to put each of these snippets (some are objects, more
are json arrays) within a .csv file.

What's the right way to escape all commas, [, ], " and other symbols so that
Excel can read it properly in the sheet?

Right now almost everything shifts after the first column of JSON in the file.
Parsing each json objects into their own columns is not what I'm looking to
do.


Answer: the `csv` module will take care of all of those things for you:

    
    
    >>> import csv, json
    >>> import StringIO
    >>> outfile = StringIO.StringIO()
    >>> writer = csv.writer(outfile)
    >>> writer.writerow([json.dumps({"hello":"world"})]*3)
    >>> print outfile.getvalue()
    "{""hello"": ""world""}","{""hello"": ""world""}","{""hello"": ""world""}"
    
    >>> 
    

