<p>As to <strong>how to convert anonymous transactions to "users"</strong> (at most a statistical attempt, as <a href="https://bitcoin.org/en/you-need-to-know#anonymous" rel="nofollow noreferrer">Bitcoin is <em>in principle</em> anonymous</a>), which could lead to your requested <strong>"users balance" info</strong>, there are papers available that describe the process. These for example could serve as a start point (with good descriptions and images): </p>

<ul>
<li><a href="http://arxiv.org/pdf/1107.4524v2.pdf" rel="nofollow noreferrer">"<em>An Analysis of Anonymity in the Bitcoin System</em>"</a> by Fergal Reid and Martin Harrigan</li>
<li><a href="http://www.mdpi.com/1999-5903/8/1/7" rel="nofollow noreferrer">"<em>Analyzing the Bitcoin Network: The First Four Years</em>" - Matthias Lischke and Benjamin Fabian, Institute of Information Systems, Humboldt-Universität zu Berlin, Spandauer Str. 1, 10178 Berlin, Germany</a> (CC BY 4.0)</li>
</ul>

<p>Basically, citing the latter: </p>

<blockquote>
  <p>... a “<em>user</em>” is a grouping of public keys that were used as inputs into a single transaction (user owns the private key to each address) ...</p>
</blockquote>

<p><a href="https://i.sstatic.net/AwR7t.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/AwR7t.png" alt="enter image description here"></a></p>

<p>As for the troubles using Python directly to treat raw data, you can use, perhaps as template or to get ideas, <a href="https://bitcoin.stackexchange.com/questions/66873/do-you-know-any-download-site-for-full-blockchain-header-data-6-in-csv-ascii-f/73987#73987">this post</a> which uses Python to convert <a href="http://headers.electrum.org/blockchain_headers" rel="nofollow noreferrer">binary block header data</a> to a CSV:</p>

<pre><code>#!/usr/bin/env python
# convert binary file http://headers.electrum.org/blockchain_headers 
# to CSV ASCII

import binascii

STRUCT_OF_BLOCK = [ 4, 32, 32, 4, 4, 4 ] # blockchain_headers does not contain always "0x00" txn_count
BLOCK_SIZE = sum(STRUCT_OF_BLOCK)

FILE_OUT= open('blockchain_headers.csv','w')

FILE_OUT.write( "version,prev_block,merkle_root,timestamp,bits,nonce,txn_count\n" )

with open('blockchain_headers','rb') as FILE:
    block = FILE.read(BLOCK_SIZE)
    while block != b'':
        position = 0
        for i in STRUCT_OF_BLOCK:
            FILE_OUT.write( bytearray(binascii.hexlify( block[position:(position+i)][::-1] )).decode('ascii') + ',')
            position += i
            if position &gt;= BLOCK_SIZE:
                FILE_OUT.write("00\n") # blockchain_headers does not contain always "0x00" txn_count
        block = FILE.read(BLOCK_SIZE)
</code></pre>

CC BY-SA 3.0
2018-04-18T18:45:33.270Z
2018-04-18T18:54:14.420Z
2018-04-18T18:54:14.420Z
circulosmeos
<p>I am doing a thesis project on modelling Bitcoin blockchain data, but atm I am having trouble getting data from the Bitcoin blockchain into a format that is easy to deal with in e.g. Python. </p>

<p>I have all data from Bitcoin Core, do you know a way to aggregate the data, into a format that would give an idea about users balance or something like this? </p>

<p>If you have ever done a similar project, I am very interested in what you have done in the preliminary phases! 
Thanks. </p>

CC BY-SA 3.0
2018-03-06T10:33:18.850Z
Address balance is possible but, user balance is not.
Willtech
CC BY-SA 3.0
2018-03-06T15:27:45.463Z
I've seen work, where the base their userID's on probabilities that addresses are the same user. This way it is possible to (with some probability) estimate the number of users and thereby the balances of specific users.

It was something like this I was thinking about.
MartJohn
<bitcoin-core><python><raw-data><user-data>
Project on modelling Bitcoin blockchain data
MartJohn
# Project on modelling Bitcoin blockchain data

(Asked by: username_0 on 2018-03-06)

I am doing a thesis project on modelling Bitcoin blockchain data, but atm I am having trouble getting data from the Bitcoin blockchain into a format that is easy to deal with in e.g. Python.

I have all data from Bitcoin Core, do you know a way to aggregate the data, into a format that would give an idea about users balance or something like this?

If you have ever done a similar project, I am very interested in what you have done in the preliminary phases!
Thanks.

**Tags:** bitcoin-core, python, raw-data, user-data

> **Comments:**
> **username_1**: Address balance is possible but, user balance is not.  
> **username_0**: I've seen work, where the base their userID's on probabilities that addresses are the same user. This way it is possible to (with some probability) estimate the number of users and thereby the balances of specific users.  It was something like this I was thinking about.  

---

## 1 answers

### Answer by username_2 on 2018-04-18. Score: 1

As to **how to convert anonymous transactions to "users"** (at most a statistical attempt, as [Bitcoin is *in principle* anonymous](https://bitcoin.org/en/you-need-to-know#anonymous)), which could lead to your requested **"users balance" info**, there are papers available that describe the process. These for example could serve as a start point (with good descriptions and images):

* ["*An Analysis of Anonymity in the Bitcoin System*"](http://arxiv.org/pdf/1107.4524v2.pdf) by Fergal Reid and Martin Harrigan
* ["*Analyzing the Bitcoin Network: The First Four Years*" - Matthias Lischke and Benjamin Fabian, Institute of Information Systems, Humboldt-Universität zu Berlin, Spandauer Str. 1, 10178 Berlin, Germany](http://www.mdpi.com/1999-5903/8/1/7) (CC BY 4.0)

Basically, citing the latter:

> ... a “*user*” is a grouping of public keys that were used as inputs into a single transaction (user owns the private key to each address) ...

[![enter image description here](https://i.sstatic.net/AwR7t.png)](https://i.sstatic.net/AwR7t.png)

As for the troubles using Python directly to treat raw data, you can use, perhaps as template or to get ideas, [this post](https://bitcoin.stackexchange.com/questions/66873/do-you-know-any-download-site-for-full-blockchain-header-data-6-in-csv-ascii-f/73987#73987) which uses Python to convert [binary block header data](http://headers.electrum.org/blockchain_headers) to a CSV:

```
#!/usr/bin/env python
# convert binary file http://headers.electrum.org/blockchain_headers 
# to CSV ASCII

import binascii

STRUCT_OF_BLOCK = [ 4, 32, 32, 4, 4, 4 ] # blockchain_headers does not contain always "0x00" txn_count
BLOCK_SIZE = sum(STRUCT_OF_BLOCK)

FILE_OUT= open('blockchain_headers.csv','w')

FILE_OUT.write( "version,prev_block,merkle_root,timestamp,bits,nonce,txn_count\n" )

with open('blockchain_headers','rb') as FILE:
    block = FILE.read(BLOCK_SIZE)
    while block != b'':
        position = 0
        for i in STRUCT_OF_BLOCK:
            FILE_OUT.write( bytearray(binascii.hexlify( block[position:(position+i)][::-1] )).decode('ascii') + ',')
            position += i
            if position >= BLOCK_SIZE:
                FILE_OUT.write("00\n") # blockchain_headers does not contain always "0x00" txn_count
        block = FILE.read(BLOCK_SIZE)

```


---

