#tabedata.txt is a file that contains the piped markdown table rows with open ('markdownrows.txt') as f: content = f.readlines() rows = [] for c in content: cells = c.split('|') cells = ['{}'.format(cell.strip()) for cell in cells] rows.append(cells) #htmltable.txt contains the html table rows file = open('htmlrows.txt', 'w+') for r in rows: file.write('\n') for c in r: file.write(' {}\n'.format(c)) file.write('\n') file.close()