Using Python's CSV library to print an array as a csv file -


i have python list such:

[['a','b','c'],['d','e','f'],['g','h','i']] 

i trying csv format can load excel:

a,b,c d,e,f g,h,i 

using this, trying write arary csv file:

with open('tables.csv','w') f:     f.write(each_table) 

however, prints out this:

[ [ ' ' , ... ... 

so tried putting array (again) , printing it.

each_table_array=[each_table] open('tables.csv','w') f:         f.write(each_table_array) 

now when open csv file, bunch of unknown characters, , when load excel, character every cell.

not sure if it's me using csv library wrong, or array portion.

i figured out table pulling data has table within 1 of cells, expands out , messes whole formatting

you need use csv library job:

import csv each_table = [['a','b','c'],['d','e','f'],['g','h','i']] open('tables.csv', 'w') csvfile:     writer = csv.writer(csvfile)     row in each_table:         writer.writerow(row) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -