Skip to content

Instantly share code, notes, and snippets.

@hjweide
Created February 5, 2017 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjweide/2ef77fc69297daa5e00777c59c64161e to your computer and use it in GitHub Desktop.
Save hjweide/2ef77fc69297daa5e00777c59c64161e to your computer and use it in GitHub Desktop.
Parse messages from a Facebook data archive.
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