I'm sure there is an easy way to do this, so here goes. I'm trying to export my lists into CSV in columns. (Basically, it's how another program will be able to use the data I've generated.) I have the group called [frames] which contains [frame001], [frame002], [frame003], etc. I would like the CSV file that's generated to have all the values for [frame001] in the first column, [frame002] in the second column, and so on. I thought if I could save the file as CSV I could manipulate it in Excel, however, I figure there is a solution that I can program to skip that step.
This is the code that I have tried using so far:
import csv
data = [frames]
out = csv.writer(open(filename,"w"), delimiter=',',quoting=csv.QUOTE_ALL)
out.writerow(data)
I have also tried:
import csv
myfile = open(..., 'wb')
wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
wr.writerow(mylist)
Most recently I have tried:
import csv
data = [frames]
out = csv.writer(open(filename,"w"), delimiter=',',quoting=csv.QUOTE_ALL)
out.writerows(zip(*data))
After more research, I'm actually needing to build an XML file, but I still need the data to be in the correct order. That is, the contents of [frame001] in a column, [frame002] in the next column, etc. All frames contain the same amount of information.
Thanks again for any assistance!
This is an example of the data for what the first 2 columns look like: [255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0, 255, 0, 0], [0, 171, 205, 0, 171, 205, 0, 171, 205, 0, 171, 205, 0, 171, 205, 0, 171, 205, 0, 171, 205, 0, 171, 205, 0, 171, 205, 0, 171, 205]
When it should be:
255 0 0 171 0 205 255 0 0 171 0 205 255 0 0 171 0 205 255 0 0 171 0 205 255 0 0 171 0 205 255 0 0 171 0 205 255 0 0 171 0 205 255 0 0 171 0 205 255 0 0 171 0 205 255 0 0 171 0 205
I hope that makes sense.