Converting CSV to XML in Python [closed]

I have csv file that looks like this:\[code\]artist,year,id,video_name,new_video_id,file_root_name,video_type,,,,,,Clay Aiken,1,clay_aiken,Sorry Seems To Be...,sorry-seems-to-be,02_sc_ca_sorry,FLVClay Aiken,1,clay_aiken,Everything I Do (I Do It For You),everything-i-do-i-do-it-for-you,03_sc_ca_everything,FLVClay Aiken,1,clay_aiken,A Thousand Days,a-thousand-days,04_sc_ca_thousandda,FLVClay Aiken,1,clay_aiken,Here You Come Again,here-you-come-again,05_sc_ca_hereyoucom,FLVClay Aiken,1,clay_aiken,Interview,interview,06_sc_ca_intv,FLV\[/code\]Each row from above would generate a separate xml file like below (5 to be precise):\[code\]<?xml version="1.0" encoding="utf-8"?><!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 2.0//EN" "http://www.w3.org/2001/SMIL20/SMIL20.dtd"><smil xmlns="http://www.w3.org/2001/SMIL20/Language"> <head> <meta base="rtmp://cp23636.edgefcs.net/ondemand" /> </head> <body> <switch> <video src="http://stackoverflow.com/questions/8672872/mp4:soundcheck/%year/%id/%file_root_name_256.mp4" system-bitrate="336000"/> <video src="http://stackoverflow.com/questions/8672872/mp4:soundcheck/%year/%id/%file_root_name_512.mp4" system-bitrate="592000"/> <video src="http://stackoverflow.com/questions/8672872/mp4:soundcheck/%year/%id/%file_root_name_768.mp4" system-bitrate="848000"/> <video src="http://stackoverflow.com/questions/8672872/mp4:soundcheck/%year/%id/%file_root_name_1128.mp4" system-bitrate="1208000"/> </switch> </body></smil>\[/code\]Naming it %new_video_id.smilI've figured out how to parse the csv file:\[code\]import csvimport sysf = open(sys.argv[1], 'rU')reader = csv.reader(f)for row in reader: year = row[1] id = row[2] file_root_name = row[5] print year, id, file_root_name\[/code\]How to I take each of the variables and include when writing the xml file?
 
Back
Top