Created
September 6, 2013 21:22
-
-
Save vanous/6470179 to your computer and use it in GitHub Desktop.
Revisions
-
vanous created this gist
Sep 6, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ input="""img.png description bbb 222 ccc 333 ddd 444 eee 555 fff 666""" #define number of columns cols=3 def process(input): #split into lines output=input.split('\n') #map for i in range(0, len(output),cols): print "<row>" #split lines into columns for col in range(0,cols): print " <entry><para><mediaobject><imageobject><imagedata fileref=\"images/%s\" align=\"center\" width=\"100%\" /></imageobject></mediaobject></para></entry>" % str(output[i+col].split('\t')[0]) print "</row>" print "<row>" for col in range(0,cols): print " <entry><para>", str(output[i+col].split('\t')[1]), "</para></entry>" print "</row>" process(input)