Created
December 13, 2011 12:37
-
-
Save goghvanmr/1471989 to your computer and use it in GitHub Desktop.
Simple Script to convert Kindle clippings to Anki import file format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
clippings = 'My Clippings.txt' | |
ankiFile = 'AnkiImport.txt' | |
def kindle_to_anki(): | |
try: | |
clippingsFile = open(clippings, 'r') | |
except IOError, e: | |
print '*** file open error: ', e | |
anki_import = open(ankiFile, 'w') | |
kindle_notes = clippingsFile.readlines() | |
anki_import.writelines(['"%s"\t"%s"\n\n' % (kindle_notes[i].strip(), kindle_notes[i+3].strip()) | |
for i in range(0, len(kindle_notes), 5)]) | |
anki_import.close() | |
clippingsFile.close() | |
if __name__ == '__main__': | |
kindle_to_anki() |
Hello michkles,
I run this script under Python 2.7 and it works. I didn't test it under Python 3.2 . The Syntax of Python 3 is different from Python 2. I think that's why it didn't work under Python 3.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! I followed your instructions but it failed to create Anki file. I put your script and My Clippings into python folder. Message from Command Line:
C:\Python32>python kindle_anki.py
File "kindle_anki.py", line 9
except IOError,e:
^
SyntaxError: invalid syntax