View Single Post
Old 03-15-2011, 06:16 PM   #2
janvanmaar
Addict
janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.janvanmaar has a complete set of Star Wars action figures.
 
Posts: 219
Karma: 404
Join Date: Nov 2010
Device: Kindle 3G, Samsung SIII
For a very basic conversion, you can use something like this:
Code:
#!/usr/bin/python
# coding: utf-8
inp='yourfile.txt'
out='outfile.txt'
new_entry=1
with open(inp) as f:
  with open(out,'w') as g:
    for line in f:
      line=line.strip()
      if new_entry:
        line+='\t'
        new_entry=0
      elif not line:
        new_entry=1 
        line='\n'
      else:
        line='<BLOCKQUOTE>'+line+'</BLOCKQUOTE>'
      g.write(line)
Just paste it exactly as it is to an empty file, modify 'yourfile.txt' to the name of your input file and save it as 'script.py' in the same directory where your input file is. Under Linux you can run it by 'python script.py' and you should have your tab delimited file.
janvanmaar is offline   Reply With Quote