Skip to content

Instantly share code, notes, and snippets.

@KrisYu
Created June 22, 2017 18:44
Show Gist options
  • Save KrisYu/e7ce7b3ea9a87820579760f0351ed748 to your computer and use it in GitHub Desktop.
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
#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