Giter VIP home page Giter VIP logo

btc_trans_toy_parser's Introduction

Bitcoin

This small project is the result of the final assignment from "Programming for Data Science" from UOC. It parses raw .json generated files that contain data from bitcoin blocks and transactions and extracts some information afterwards. It is a toy tool only meant to get comfortable programming and debugging with an IDE

Author

Aitor
Github
Linkedin

Getting Started

These instructions will get us a copy of the project up and running on our local machine. First of all the repository has been tested with a virtual machine with roughly ~5MBs of RAM and 2 CPUS, to be able to fit in memory the txs.json and store it into a dictionary. Even though the file needs 1.1GByte for storage it requires significantly more memory to perform operations on it. It might work with less memory.
First of all, if we are not using an IDE like Pycharm, that automatically sets up a virtual environment for us, we will need to open a terminal and make a virtual environment by ourselves by typing the following command:

python3 -m venv Bitcoin

This will create a virtual environment called "Bitcoin" on our local machine, in the current directory. Next we will activate the virtual environment, with the following command:

source Bitcoin/bin/activate

Because we just created this virtual environment, it is empty and we need to install the dependencies (libraries) that the software needs to run correctly. To do that we just run the following command:

pip install -r requirements.txt

Because Pycharm can show the following error message: "Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. plt.show() " it is recommended to install tkinter running the following command:

 sudo apt-get install python3.6-tk

Now, in order to run this package we simply need to run the main.py file with the following command:

python3 main.py

Now, the main.py file has some options based on preferences: We can assign different variables to the parameters PATH, TRANSACTIONS, BLOCKS, CONTROL_TIME, based on where we have the source files or if we want to display additional information about the time it takes to parse those files.

Static method:

We might have the files in our Desktop rather than in the ./Downloads folder. Thus, we would assign os.path.join(os.path.expanduser('~'), 'Desktop') to PATH.
We might even have a different .json called random.json with transactions data. Then, we would assign os.path.join(PATH, 'random.json') to TRANSACTIONS.
We might want to control the execution time of the parsing of this file. Then, we would assign True to CONTROL_TIME

Dynamic method:

This is a more advanced method, more convenient, that allows us to change those parameters in-the-run when we execute the file, without changing any line of the original code, for example:

We can run python3 main.py --path /home/datasci/Desktop or a simplified command: python3 main.py -p /home/datasci/Desktop if we have the .json files there\

We can also run python3 main.py --transactions /home/datasci/Downloads/random.json or a simplified command: python3 main.py -t /home/datasci/Downloads/random.json to tell the program we have a file called random.json instead of txs.json.\

Or we can run python3 main.py --control_time True or a simplified command: python3 main.py -ctrl True to display the execution time of the parsing of the .json file

Or we might run two of them with the simplified version:
python3 main.py -p /home/datasci/Downloads -ctrl True

The program should take around ~20 seconds to execute using an average laptop

Structure of the repository

As we have already mentioned, the main goal of this mini-project is to parse and extract information from raw .json files that contain data about bitcoin blocks and transactions. The package data contains a script that parses the .json files and extracts information from them, as well as draws some interactive plots (THERE IS ONLY ONE AT THE MOMENT). The module tests must be run from the same module and makes sure all the functions contained in the module data.dataset work fine (THERE IS ONLY ONE AT THE MOMENT). Last but not least, the module main.py puts everything together and allows us to use different values for the parameters in order to display the information that we want. For example, we could decide that we want to display or to not display the execution time for the loading part of the dataset, by passing True or False to the parameter CTRL_TIME. If we don't want to use this parameter it will display the execution time by default.

The dataset

The dataset consists of two .json files containing a subset of bitcoin transactions and blocks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.