Created
May 25, 2015 04:45
-
-
Save t27/5f1c2127e75bdae6ca8e to your computer and use it in GitHub Desktop.
A python script to convert a spreadsheet(in CSV format) to a question-answer type document(where the heading of each column is the question and each row is an answer), generally useful to generate readable documents from surveys or similar spread sheets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#a script to convert a spreadsheet to a question-answer type document(where the heading of each column is the question and each row is an answer), generally useful to generate readable documents from surveys or similar spread sheets | |
import csv | |
with open('survey.csv', 'rb') as csvfile: | |
reader = csv.reader(csvfile) | |
csv_as_list = list(reader) | |
titles=csv_as_list[0]; | |
for i in range(1,len(csv_as_list)): | |
print "=================================================================="; | |
for j in range(len(csv_as_list[i])): | |
print "\n"+titles[j]+"\n" | |
if(csv_as_list[i][j].strip()==""): | |
print "NA\n" | |
else: | |
print csv_as_list[i][j]+"\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment