/
read_dat.py
58 lines (37 loc) · 951 Bytes
/
read_dat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-
"""
Examples for using dat class
"""
# %% Imports
from pybit.py3.chain import Dat
# %% Read .dat
path = 'Blocks/'
f = 'blk00003.dat'
dat = Dat(path, f,
verb=1)
# Read the block
dat.read_next_block()
# Verify it's correct (this may already have been done on import)
dat.blocks[0].api_verify()
# Output block data as dict
dat.blocks[0].to_dict()
# %% Read another 10 blocks and export
# Read block
dat.verb = 1
dat.read_next_block(500)
# Export to pandas df
blockTable = dat.blocks_to_pandas()
blockTable.head()
# %% Print example transaction
print(dat.blocks[0].trans[0]._print())
# %% Verify it's correct
dat.blocks[0].trans[0].api_verify()
# %% Print example transaction
print(dat.blocks[0].trans[0])
# %% Verify it's correct
dat.blocks[0].trans[0].api_verify()
# %% Convert block transaction to pandas df
transTable = dat.trans_to_pandas()
transTable.head()
# %% Read all blocks
dat.read_all()