samedi 28 février 2015

exporting data into a column of an excel file in python

here is my code:



import random
from random import shuffle

fileName = 'test'
dataFile = open("DD" + fileName+'.csv', 'w')
dataFile.write('trial,numbers') #data headers for .csv file

a = [1,2]

for i in range(4):
shuffle(a)
if a == [1,2]:
num = 'top'
else:
num = 'bottom'

print a
print num

info = []
i = str(i)
info.append(',')
info.append(i)
info.append(',')
info.append(num)

dataFile.writelines(info)


This code randomizes an order than labels it top or bottom 4 times, and exports the a excel file. The problem is that when it exports it puts it in a row. What I would like to do is have it exported into a column so that they are under the headlines 'trial' and 'numbers'. Any help would be greatly appreciated. :)


Aucun commentaire:

Enregistrer un commentaire