Writing a Python list of lists to a csv file
Question: I have a long list of lists of the following form ---

    
    
    a = [[1.2,'abc',3],[1.2,'werew',4],........,[1.4,'qew',2]]
    

i.e. the values in the list are of different types -- float,int, strings.How
do I write it into a csv file so that my output csv file looks like

    
    
    1.2,abc,3
    1.2,werew,4
    .
    .
    .
    1.4,qew,2
    


Answer: Python's built-in [CSV module](http://docs.python.org/2/library/csv.html) can
handle this easily:

    
    
    import csv
    
    with open("output.csv", "wb") as f:
        writer = csv.writer(f)
        writer.writerows(a)
    

This assumes your list is defined as `a`, as it is in your question. You can
tweak the exact format of the output CSV via the various optional parameters
to `csv.writer()` as documented in the library reference page linked above.

