4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

Finding the number of authors/voters/... per day with Python

![](https://steemitimages.com/p/EEEoA8oLaAxtVnttk7BKQMhRXkrRt8FHqw3nZvGBTSbDiXEyysnzqBxDdLg9XNkgwRqT1aKC47fM48GVLzPFotTDyUX64frd7KDRtYKKiKsSGK5H6vGrtDhh36LqKBVfhr8KfXab3aszWzvEyAatw?format=match&mode=fit&width=640) Image: [Timur Saglambilek](https://www.pexels.com/photo/analytics-text-185576/)

Just used a similar variant for another purpose, maybe it's helpful for somebody else as well. This script uses beem to access the blockchain.

from beem.blockchain import Blockchain
from datetime import datetime, timedelta
import sys

start_time = datetime(2019, 5, 29)
bc = Blockchain()
start_block = bc.get_estimated_block_num(start_time)
stop_block = bc.get_estimated_block_num(start_time +
                                        timedelta(days=1))
root_authors = set()
comment_authors = set()
voters = set()
transactors = set()
for op in bc.stream(start=start_block, stop=stop_block,
                    max_batch_size=50):
    sys.stdout.write("%s\r" % (op['timestamp']))
    if op['type'] == 'comment':
        if op['parent_author']:
            comment_authors |= set([op['author']])
        else:
            root_authors |= set([op['author']])
    if op['type'] == 'vote':
        voters |= set([op['voter']])
    if op['type'] == 'transfer':
        transactors |= set([op['from']])

print("\nNumber of root authors    : %d" % (len(root_authors)))
print("Number of comment authors : %d" % (len(comment_authors)))
print("Number of voters          : %d" % (len(voters)))
print("Number of transfer senders: %d" % (len(transactors)))

A few remarks:

  • blockchain.get_estimated_block_num() is a nice way to get a block number form a time stamp and is used to find the start and stop blocks.
  • The set()s are an elegant way to keep track of a list of unique entries, or'ing with |= adds new values only if they are not yet contained in the set
  • The sys.stdout.write() with line-return gives some status info on how far in time the script has the data processed and only little output clutter to the terminal

Results for May 29th, 2019

Number of root authors 6247
Number of comment authors 4129
Number of voters 41559
Number of transfer senders 2929

Wow, the numbers aren't very promising :/ We had ~8k root posters and ~6k comment authors beginning of the year and more than 10k/8k (root/comment) around Sept. 2018. The number of voters per day also seems to be declining, coming from around 47k at the beginning of the year and >50k in Sept '18. number references.

141 upvotes $1.04

Replies (2)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: