SHOW:
|
|
- or go back to the newest paste.
| 1 | import csv | |
| 2 | ||
| 3 | _INPUT_FILENAME = "bookmarks.csv" | |
| 4 | _OUTPUT_FILENAME = "bookmarks.html" | |
| 5 | ||
| 6 | fout = open(_OUTPUT_FILENAME, 'w') | |
| 7 | csvfile = open(_INPUT_FILENAME, 'rb') | |
| 8 | ||
| 9 | # Write the header | |
| 10 | fout.write("""<!DOCTYPE NETSCAPE-Bookmark-file-1>
| |
| 11 | <!-- This is an automatically generated file. | |
| 12 | It will be read and overwritten. | |
| 13 | DO NOT EDIT! --> | |
| 14 | <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> | |
| 15 | <TITLE>Bookmarks</TITLE> | |
| 16 | <H1>Bookmarks</H1> | |
| 17 | <DL><p>\n""") | |
| 18 | ||
| 19 | csvreader = csv.reader(csvfile, delimiter=';', quotechar='"') | |
| 20 | for row in csvreader: | |
| 21 | fout.write('\t<DT><A HREF="')
| |
| 22 | fout.write(row[1]) | |
| 23 | fout.write('">')
| |
| 24 | fout.write(row[0]) | |
| 25 | fout.write('</A>\n')
| |
| 26 | ||
| 27 | fout.write('</DL><p>\n')
| |
| 28 | ||
| 29 | fout.close() | |
| 30 | csvfile.close(); |