Created
February 5, 2017 02:30
-
-
Save hjweide/2ef77fc69297daa5e00777c59c64161e to your computer and use it in GitHub Desktop.
Parse messages from a Facebook data archive.
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
def main(): | |
inpath = 'messages.txt' | |
outpath = 'parsed.txt' | |
name = 'First Last' | |
marker = '%s:' % name | |
with open(inpath, 'r') as fin, open(outpath, 'w') as fout: | |
for line in fin.readlines(): | |
if marker in line: | |
message = line.split(marker)[1].strip() | |
if message: | |
fout.write('%s\n' % message) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment