Created
June 22, 2017 18:44
-
-
Save KrisYu/e7ce7b3ea9a87820579760f0351ed748 to your computer and use it in GitHub Desktop.
use on Mac,split My Clippings.txt by booktitle ( 4 year old script
This file contains 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
#filename: kindlesplit.py | |
f=open('My Clippings.txt').read() | |
notes = f.split('==========\r\n') | |
lines = [] | |
booktitle = [] | |
lines = notes[:] | |
for i in range(len(lines)): | |
lines[i]=lines[i].split('\r\n') | |
booktitle.append(lines[i][0]) | |
booktitle = list(set(booktitle)) | |
for i in range(1,len(booktitle)): | |
filename = booktitle[i].decode('utf-8') + '.txt' | |
thefile = open(filename,'w') | |
for j in range(len(notes)): | |
if booktitle[i]==lines[j][0]: | |
thefile.write(notes[j]) | |
thefile.write('\r\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment