Skip to content

Instantly share code, notes, and snippets.

@ronreiter
Created April 6, 2018 13:57
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 ronreiter/d6caae55254fa6d37104cecc2a596514 to your computer and use it in GitHub Desktop.
Save ronreiter/d6caae55254fa6d37104cecc2a596514 to your computer and use it in GitHub Desktop.
Facebook post stats
from collections import Counter
name = None
in_text = False
current_text = ""
all_text = []
for line in open("stats.txt"):
#print('current line: %s in_text: %s name: %s' % (line.strip(), in_text, name))
line = line.strip()
if line == 'Manage' or 'Reply' in line:
in_text = False
if current_text:
print(current_text.strip())
all_text.append(current_text.strip())
current_text = ""
continue
if name and not in_text and line.startswith(name):
in_text = True
current_text += line[len(name)+1:] + " "
continue
if in_text:
current_text += line + " "
continue
if len(line) > 5:
name = line
count = Counter(all_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment