Skip to content

Instantly share code, notes, and snippets.

@theharshbhatia
Created October 6, 2013 11:21
Show Gist options
  • Select an option

  • Save theharshbhatia/6852791 to your computer and use it in GitHub Desktop.

Select an option

Save theharshbhatia/6852791 to your computer and use it in GitHub Desktop.

Revisions

  1. @hash113 hash113 created this gist Oct 6, 2013.
    23 changes: 23 additions & 0 deletions txt2xml.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #"Convert text file into xml"
    #by Hash113
    k=[]
    q=open("quote.txt")
    d=open("final.txt",'w')
    i=0
    w=q.readlines()
    for i in range(0,len(w)-1):
    f=w[i]
    a=w[i+1]
    a=a.strip()
    f=f.strip()
    if (len(f)>14):
    quote=f
    d.write("<note>\n\t<author>"+a+"</author>\n\t<tag></tag>\n\t<quote>"+f+"</quote>\n</note>\n\n")

    """
    <note>
    <author>Albert Einstein</author>
    <tag>Victory</tag>
    <quote>Failure is just a state of mind</quote>
    </note>
    """