create account

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

View this thread on: hive.blogpeakd.comecency.com
· @stmdev · (edited)
$4.35
Finding the number of authors/voters/... per day with Python
<center>![](https://steemitimages.com/p/EEEoA8oLaAxtVnttk7BKQMhRXkrRt8FHqw3nZvGBTSbDiXEyysnzqBxDdLg9XNkgwRqT1aKC47fM48GVLzPFotTDyUX64frd7KDRtYKKiKsSGK5H6vGrtDhh36LqKBVfhr8KfXab3aszWzvEyAatw?format=match&mode=fit&width=640)
<sup>Image: [Timur Saglambilek](https://www.pexels.com/photo/analytics-text-185576/)</sup></center>

Just used a similar variant for another purpose, maybe it's helpful for somebody else as well. This script uses [beem](https://github.com/holgern/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. <sup>[number references](https://steemit.com/utopian-io/@crokkon/how-much-of-the-total-steem-sp-is-not-voting-1543014210145)</sup>.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 77 others
properties (23)
authorstmdev
permlinkfinding-the-number-of-authors-voters-per-day-with-python
categorypython
json_metadata{"community":"busy","app":"busy/2.5.6","format":"markdown","tags":["python","beem","statistics","tutorial","busy"],"users":["crokkon"],"links":["https://www.pexels.com/photo/analytics-text-185576/","https://github.com/holgern/beem","https://steemit.com/utopian-io/@crokkon/how-much-of-the-total-steem-sp-is-not-voting-1543014210145"],"image":["https://steemitimages.com/p/EEEoA8oLaAxtVnttk7BKQMhRXkrRt8FHqw3nZvGBTSbDiXEyysnzqBxDdLg9XNkgwRqT1aKC47fM48GVLzPFotTDyUX64frd7KDRtYKKiKsSGK5H6vGrtDhh36LqKBVfhr8KfXab3aszWzvEyAatw?format=match&mode=fit&width=640"]}
created2019-05-30 19:36:33
last_update2019-05-30 19:38:06
depth0
children2
last_payout2019-06-06 19:36:33
cashout_time1969-12-31 23:59:59
total_payout_value3.312 HBD
curator_payout_value1.040 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,729
author_reputation10,427,398,400,460
root_title"Finding the number of authors/voters/... per day with Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id85,767,370
net_rshares8,417,886,775,023
author_curate_reward""
vote details (141)
@steemitboard ·
Congratulations @stmdev! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<table><tr><td><img src="https://steemitimages.com/60x70/http://steemitboard.com/@stmdev/voted.png?201905302147"></td><td>You received more than 2000 upvotes. Your next target is to reach 3000 upvotes.</td></tr>
</table>

<sub>_You can view [your badges on your Steem Board](https://steemitboard.com/@stmdev) and compare to others on the [Steem Ranking](http://steemitboard.com/ranking/index.php?name=stmdev)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



###### [Vote for @Steemitboard as a witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1) to get one more award and increased upvotes!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-stmdev-20190530t225941000z
categorypython
json_metadata{"image":["https://steemitboard.com/img/notify.png"]}
created2019-05-30 22:59:39
last_update2019-05-30 22:59:39
depth1
children0
last_payout2019-06-06 22:59:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length836
author_reputation38,975,615,169,260
root_title"Finding the number of authors/voters/... per day with Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id85,775,895
net_rshares0
@windenchanter ·
This is very useful. Thank you for sharing!

Posted using [Partiko Android](https://partiko.app/referral/windenchanter)
properties (22)
authorwindenchanter
permlinkwindenchanter-re-stmdev-finding-the-number-of-authors-voters-per-day-with-python-20190708t033705154z
categorypython
json_metadata{"app":"partiko","client":"android"}
created2019-07-08 03:37:06
last_update2019-07-08 03:37:06
depth1
children0
last_payout2019-07-15 03:37:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length119
author_reputation1,892,764,897,686
root_title"Finding the number of authors/voters/... per day with Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id87,975,737
net_rshares0