python - Manipulate CSV file 1 column into multiple - NFL scores -


working on nfl csv file can me automate scoring games. right now, can upload teams , scores 1 column of csv file.

these in column a

example: a

1   nyj 2   27 3   phi 4   20 5   buf 6   13 7   det 8   35 9   cin 10  27 11  ind 12  10 13  mia 14  24 15  no 16  21 

or

[['nyj`'], ['27'], ['phi'], ['20'], ['buf'], ['13'], ['det'], ['35'], ['cin'], ['27'], ['ind'], ['10'], ['mia'], ['24'], ['no'], ['21'], ['tb'], ['12'], ['was'], ['30'], ['car'], ['25'], ['pit'], ['10'], ['atl'], ['16'], ['jac'], ['20'], ['ne'], ['28'], ['nyg'], ['20'], ['min'], ['24'], ['ten'], ['23'], ['stl'], ['24'], ['bal'], ['21'], ['chi'], ['16'], ['cle'], ['18'], ['kc'], ['30'], ['gb'], ['8'], ['dal'], ['6'], ['hou'], ['24'], ['den'], ['24'], ['ari'], ['32'], ['sd'], ['6'`], ['sf'], ['41'], ['sea'], ['22'], ['oak'], ['6']] 

what want this:

    b   c  d 1 nyj 27 phi 20 2 buf 13 det 35 3 cin 27 ind 10 4 mia 24 no  21 

i have read through previous articles on , have not got work yet. ideas on this?

any appreciated , thanks!

current script:

import nflgame import csv print "purpose of script nfl scores out gut"  pregames = nflgame.games(2013, week=[4], kind='pre')  out = open("scores.csv", "wb") output = csv.writer(out)  score in pregames:     output.writerows([[score.home],[score.score_home],[score.away],[score.score_away]]) 

you're using .writerows() write 4 rows, each 1 column.

instead, want:

output.writerow([score.home, score.score_home, score.away, score.score_away]) 

to write single row 4 columns.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -