Here's a short python script I've been using to generate an events file. Personally, I find it easier to layout the time line in a spreadsheet.

-d

--
You received this message because you are subscribed to the Google Groups "SIMILE 
Widgets" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/simile-widgets?hl=en.

import csv
#
# Converts a CSV file into a timeline js file
# Input: a CSV something like this:
# 
"start","end","title","description","image","link","color","textcolor","caption"
# First row is the field names
# Redirect into your data file (i.e, 'local_data.js')
#
csvfile  = open('timeline.csv', "rb")
reader = csv.reader(csvfile)
print("""var timeline_data = {  // save as a global variable
'dateTimeFormat': 'iso8601',

'events' : [""")
rownum = 0
for row in reader:
    # header row contains field names.
    if rownum == 0:
        header = row
    else:
        colnum = 0
        print '\t{'
        firstCol = True
        for col in row:
            if len(col) != 0:
                if firstCol:
                    firstCol = False
                else:
                    print ","
                print "\t'%s': '%s'" % (header[colnum], col),
                colnum += 1
        print "\n\t}"
    rownum += 1
print "]\n}"
csvfile.close()

Reply via email to