Skip to content

Instantly share code, notes, and snippets.

@vanous
Created September 6, 2013 21:22
Show Gist options
  • Select an option

  • Save vanous/6470179 to your computer and use it in GitHub Desktop.

Select an option

Save vanous/6470179 to your computer and use it in GitHub Desktop.

Revisions

  1. vanous created this gist Sep 6, 2013.
    34 changes: 34 additions & 0 deletions gistfile1.py
    Original 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)