1

I want to save a 2D array data into a CSV file in Python. But there is always a blank line between each line. Also, I want to save each element in the array into an individual space instead of saving the whole row data into one space. Please help me solve this problem. Thanks. The following code is just an example.

    from Tkinter import filedialog
    import CSV

    array=[[1,2,3], [4,5,6], [7,8,9]]
    filesave = filedialog.asksaveasfile(mode='w', defaultextension=".csv")
    csvfile = csv.writer(filesave)

    csvfile.writerows(array)
Hualong Du
  • 11
  • 1

0 Answers0