Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- _INPUT_FILENAME = "bookmarks.csv"
- _OUTPUT_FILENAME = "bookmarks.html"
- fout = open(_OUTPUT_FILENAME, 'w')
- csvfile = open(_INPUT_FILENAME, 'rb')
- # Write the header
- fout.write("""<!DOCTYPE NETSCAPE-Bookmark-file-1>
- <!-- This is an automatically generated file.
- It will be read and overwritten.
- DO NOT EDIT! -->
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
- <TITLE>Bookmarks</TITLE>
- <H1>Bookmarks</H1>
- <DL><p>\n""")
- csvreader = csv.reader(csvfile, delimiter=';', quotechar='"')
- for row in csvreader:
- fout.write('\t<DT><A HREF="')
- fout.write(row[1])
- fout.write('">')
- fout.write(row[0])
- fout.write('</A>\n')
- fout.write('</DL><p>\n')
- fout.close()
- csvfile.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement