SHARE
TWEET

Untitled

a guest Dec 29th, 2011 43 Never
  1. with open(sys.argv[1], 'rU') as f:
  2.     reader = csv.DictReader(f)
  3.     for row in reader:
  4.         switch_tag = ElementTree.Element('switch')
  5.  
  6.         attrs = {'src': ("mp4:soundcheck/{year}/{id}/{file_root_name}_256.mp4".format(**row)),'system-bitrate': '336000',}
  7.         attrs = {'src': ("mp4:soundcheck/{year}/{id}/{file_root_name}_512.mp4".format(**row)),'system-bitrate': '592000',}
  8.         attrs = {'src': ("mp4:soundcheck/{year}/{id}/{file_root_name}_768.mp4".format(**row)),'system-bitrate': '848000',}
  9.         attrs = {'src': ("mp4:soundcheck/{year}/{id}/{file_root_name}_1128.mp4".format(**row)),'system-bitrate': '1208000',}
  10.        
  11.         ElementTree.SubElement(switch_tag, 'video', attrs)
  12.         print minidom.parseString(ElementTree.tostring(switch_tag)).toprettyxml()
  13.  
  14. print minidom.parseString(ElementTree.tostring(switch_tag)).toprettyxml()
  15.  
  16. I want to look like:
  17.  
  18.     <switch>
  19.       <video src="mp4:soundcheck/2006/clay_aiken/02_sc_ca_sorry_256.mp4" system-bitrate="336000"/>
  20.       <video src="mp4:soundcheck/2006/clay_aiken/02_sc_ca_sorry_512.mp4" system-bitrate="592000"/>
  21.       <video src="mp4:soundcheck/2006/clay_aiken/02_sc_ca_sorry_768.mp4" system-bitrate="848000"/>
  22.       <video src="mp4:soundcheck/2006/clay_aiken/02_sc_ca_sorry_1128.mp4" system-bitrate="1208000"/>
  23.     </switch>
RAW Paste Data
Top