├── MANIFEST.in
├── _config.yml
├── cellyzer.egg-info
├── dependency_links.txt
├── top_level.txt
├── requires.txt
├── SOURCES.txt
└── PKG-INFO
├── .idea
├── .gitignore
├── rSettings.xml
├── vcs.xml
├── inspectionProfiles
│ └── profiles_settings.xml
├── misc.xml
├── modules.xml
└── cellyzer - CDR data analyzer.iml
├── .vscode
└── settings.json
├── dist
├── cellyzer-1.0.0.tar.gz
├── cellyzer-1.0.1.tar.gz
├── cellyzer-1.1.0.tar.gz
├── cellyzer-1.1.1.tar.gz
├── cellyzer-1.1.2.tar.gz
├── cellyzer-1.1.3.tar.gz
├── cellyzer-1.1.4.tar.gz
├── cellyzer-1.0.0-py3-none-any.whl
├── cellyzer-1.0.1-py3-none-any.whl
├── cellyzer-1.1.0-py3-none-any.whl
├── cellyzer-1.1.1-py3-none-any.whl
├── cellyzer-1.1.2-py3-none-any.whl
├── cellyzer-1.1.3-py3-none-any.whl
└── cellyzer-1.1.4-py3-none-any.whl
├── cellyzer_gui
├── assets
│ ├── add-call.gif
│ ├── add-dataset.gif
│ ├── functions.gif
│ ├── logo-cellyzer.png
│ └── gui.css
├── test
│ ├── chromedriver.exe
│ ├── antennas.csv
│ ├── messages.csv
│ ├── calls.csv
│ └── test.py
└── outputs
│ └── map.html
├── .ipynb_checkpoints
├── demo_user_notebook-checkpoint.ipynb
├── demo_cell_data_notebook-checkpoint.ipynb
├── demo_msg_data_notebook-checkpoint.ipynb
└── demo_call_data_notebook-checkpoint.ipynb
├── visualization_images
├── active_time.png
├── cellyzer_logo.png
├── connection_network.png
├── home_work_location.png
├── trip_visualization.png
└── pupulation_around_cell_2.png
├── cellyzer
├── __pycache__
│ ├── core.cpython-38.pyc
│ ├── io.cpython-38.pyc
│ ├── tools.cpython-38.pyc
│ ├── utils.cpython-38.pyc
│ ├── __init__.cpython-38.pyc
│ └── visualization.cpython-38.pyc
├── __init__.py
├── matrix.py
├── utils.py
├── tools.py
└── visualization.py
├── demo
├── demo_datasets
│ ├── test_data
│ │ ├── excel data
│ │ │ ├── calls.xlsx
│ │ │ ├── cell.xlsx
│ │ │ └── messages.xlsx
│ │ ├── antennas.csv
│ │ ├── messages.csv
│ │ ├── json data
│ │ │ ├── cell.json
│ │ │ ├── message.json
│ │ │ └── call.json
│ │ └── calls.csv
│ └── long_data
│ │ └── antennas.csv
├── records_of_2_users.csv
├── demo_cell.py
├── demo_message.py
├── demo_user.py
├── demo_calls.py
└── .ipynb_checkpoints
│ ├── demo_user_notebook-checkpoint.ipynb
│ └── demo_msg_data_notebook-checkpoint.ipynb
├── .gitignore
├── tests
├── performance_tests
│ ├── test_IO.py
│ └── test_CORE.py
└── unit_tests
│ ├── test_MessageDataSet.py
│ ├── test_CallDataSet.py
│ ├── test_user.py
│ ├── test_CallMessageDataSet.py
│ ├── test_io.py
│ └── test_CellDataSet.py
├── LICENSE
├── setup.py
└── README.md
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include README.md LICENCE
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-midnight
--------------------------------------------------------------------------------
/cellyzer.egg-info/dependency_links.txt:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/cellyzer.egg-info/top_level.txt:
--------------------------------------------------------------------------------
1 | cellyzer
2 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /workspace.xml
3 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "python.pythonPath": "C:\\Users\\chama\\AppData\\Local\\Programs\\Python\\Python37\\python.exe"
3 | }
--------------------------------------------------------------------------------
/dist/cellyzer-1.0.0.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.0.0.tar.gz
--------------------------------------------------------------------------------
/dist/cellyzer-1.0.1.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.0.1.tar.gz
--------------------------------------------------------------------------------
/dist/cellyzer-1.1.0.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.1.0.tar.gz
--------------------------------------------------------------------------------
/dist/cellyzer-1.1.1.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.1.1.tar.gz
--------------------------------------------------------------------------------
/dist/cellyzer-1.1.2.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.1.2.tar.gz
--------------------------------------------------------------------------------
/dist/cellyzer-1.1.3.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.1.3.tar.gz
--------------------------------------------------------------------------------
/dist/cellyzer-1.1.4.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.1.4.tar.gz
--------------------------------------------------------------------------------
/.idea/rSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/cellyzer_gui/assets/add-call.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/cellyzer_gui/assets/add-call.gif
--------------------------------------------------------------------------------
/cellyzer_gui/assets/add-dataset.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/cellyzer_gui/assets/add-dataset.gif
--------------------------------------------------------------------------------
/cellyzer_gui/assets/functions.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/cellyzer_gui/assets/functions.gif
--------------------------------------------------------------------------------
/cellyzer_gui/test/chromedriver.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/cellyzer_gui/test/chromedriver.exe
--------------------------------------------------------------------------------
/.ipynb_checkpoints/demo_user_notebook-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 4
6 | }
7 |
--------------------------------------------------------------------------------
/cellyzer_gui/assets/logo-cellyzer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/cellyzer_gui/assets/logo-cellyzer.png
--------------------------------------------------------------------------------
/dist/cellyzer-1.0.0-py3-none-any.whl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.0.0-py3-none-any.whl
--------------------------------------------------------------------------------
/dist/cellyzer-1.0.1-py3-none-any.whl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.0.1-py3-none-any.whl
--------------------------------------------------------------------------------
/dist/cellyzer-1.1.0-py3-none-any.whl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.1.0-py3-none-any.whl
--------------------------------------------------------------------------------
/dist/cellyzer-1.1.1-py3-none-any.whl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.1.1-py3-none-any.whl
--------------------------------------------------------------------------------
/dist/cellyzer-1.1.2-py3-none-any.whl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.1.2-py3-none-any.whl
--------------------------------------------------------------------------------
/dist/cellyzer-1.1.3-py3-none-any.whl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.1.3-py3-none-any.whl
--------------------------------------------------------------------------------
/dist/cellyzer-1.1.4-py3-none-any.whl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/dist/cellyzer-1.1.4-py3-none-any.whl
--------------------------------------------------------------------------------
/visualization_images/active_time.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/visualization_images/active_time.png
--------------------------------------------------------------------------------
/.ipynb_checkpoints/demo_cell_data_notebook-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 4
6 | }
7 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/demo_msg_data_notebook-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [],
3 | "metadata": {},
4 | "nbformat": 4,
5 | "nbformat_minor": 4
6 | }
7 |
--------------------------------------------------------------------------------
/cellyzer/__pycache__/core.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/cellyzer/__pycache__/core.cpython-38.pyc
--------------------------------------------------------------------------------
/cellyzer/__pycache__/io.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/cellyzer/__pycache__/io.cpython-38.pyc
--------------------------------------------------------------------------------
/visualization_images/cellyzer_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/visualization_images/cellyzer_logo.png
--------------------------------------------------------------------------------
/cellyzer/__pycache__/tools.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/cellyzer/__pycache__/tools.cpython-38.pyc
--------------------------------------------------------------------------------
/cellyzer/__pycache__/utils.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/cellyzer/__pycache__/utils.cpython-38.pyc
--------------------------------------------------------------------------------
/cellyzer/__pycache__/__init__.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/cellyzer/__pycache__/__init__.cpython-38.pyc
--------------------------------------------------------------------------------
/visualization_images/connection_network.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/visualization_images/connection_network.png
--------------------------------------------------------------------------------
/visualization_images/home_work_location.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/visualization_images/home_work_location.png
--------------------------------------------------------------------------------
/visualization_images/trip_visualization.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/visualization_images/trip_visualization.png
--------------------------------------------------------------------------------
/cellyzer.egg-info/requires.txt:
--------------------------------------------------------------------------------
1 | xlrd==1.2.0
2 | numpy==1.18.2
3 | tabulate==0.8.7
4 | datetime==4.3
5 | networkx==2.4
6 | matplotlib==3.2.1
7 | folium==0.10.1
8 | IPython
9 |
--------------------------------------------------------------------------------
/cellyzer/__pycache__/visualization.cpython-38.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/cellyzer/__pycache__/visualization.cpython-38.pyc
--------------------------------------------------------------------------------
/demo/demo_datasets/test_data/excel data/calls.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/demo/demo_datasets/test_data/excel data/calls.xlsx
--------------------------------------------------------------------------------
/demo/demo_datasets/test_data/excel data/cell.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/demo/demo_datasets/test_data/excel data/cell.xlsx
--------------------------------------------------------------------------------
/visualization_images/pupulation_around_cell_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/visualization_images/pupulation_around_cell_2.png
--------------------------------------------------------------------------------
/demo/demo_datasets/test_data/excel data/messages.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anjuchamantha/cellyzer---CDR-data-analyzer/HEAD/demo/demo_datasets/test_data/excel data/messages.xlsx
--------------------------------------------------------------------------------
/demo/records_of_2_users.csv:
--------------------------------------------------------------------------------
1 | _user,_other,_direction,_length,_timestamp
2 | 329233d117,,Incoming,7,Mon Feb 11 07:08:49 +0000 1980
3 | 329233d117,,Outgoing,6,Mon Feb 11 07:14:05 +0000 1980
4 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | cellyzer/__pycache__/
3 |
4 | active_time_bar_chart.html
5 | connection_matrix.html
6 | connection_network.html
7 | population_map.html
8 | trip_map.html
9 | home_work_location.html
10 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/cellyzer/__init__.py:
--------------------------------------------------------------------------------
1 | __all__ = ['core', 'io', 'utils']
2 |
3 | from .io import read_csv, to_csv, to_json, read_call, read_msg, read_cell
4 | from .core import CallRecord, MessageRecord, CellRecord, CallDataSet, MessageDataSet, CellDataSet, User
5 | from . import utils, io, core, visualization, tools, matrix
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/cellyzer - CDR data analyzer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/cellyzer.egg-info/SOURCES.txt:
--------------------------------------------------------------------------------
1 | MANIFEST.in
2 | README.md
3 | setup.py
4 | cellyzer/__init__.py
5 | cellyzer/core.py
6 | cellyzer/io.py
7 | cellyzer/matrix.py
8 | cellyzer/tools.py
9 | cellyzer/utils.py
10 | cellyzer/visualization.py
11 | cellyzer.egg-info/PKG-INFO
12 | cellyzer.egg-info/SOURCES.txt
13 | cellyzer.egg-info/dependency_links.txt
14 | cellyzer.egg-info/requires.txt
15 | cellyzer.egg-info/top_level.txt
--------------------------------------------------------------------------------
/cellyzer_gui/test/antennas.csv:
--------------------------------------------------------------------------------
1 | antenna_id,latitude,longitude
2 | 1,42.366944,-71.083611
3 | 2,42.386722,-71.138778
4 | 3,42.3604,-71.087374
5 | 4,42.353917,-71.105
6 | 5,42.36,-71.12
7 | 6,42.375,-71.1
8 | 7,42.345,-71.09
9 | 8,42.39,-71.105
10 | 9,42.38,-71.09
11 | 10,42.304917,-71.147374
12 | 11,42.373917,-70.067374
13 | 12,42.313917,-71.037374
14 | 13,42.40944,-71.1
15 | 14,42.41,-71.073
16 | 15,42.44,-71.15
17 | 16,42.48,-71.23
18 | 17,42.35,-71.05
19 | 18,42.33,-71.11
20 | 19,42.36,-71.25
21 | 20,42.413,-71.143
22 | 21,42.373917,-71.215
23 | 22,43.37,-71.085
24 | 23,43.39,-71.11
25 | 24,42.29,-71.13
26 | 25,42.31,-71.16
27 | 26,42.313,-71.135
28 | 27,42.297,-71.155
29 |
--------------------------------------------------------------------------------
/demo/demo_datasets/long_data/antennas.csv:
--------------------------------------------------------------------------------
1 | antenna_id,latitude,longitude
2 | 1,42.366944,-71.083611
3 | 2,42.386722,-71.138778
4 | 3,42.3604,-71.087374
5 | 4,42.353917,-71.105
6 | 5,42.36,-71.12
7 | 6,42.375,-71.1
8 | 7,42.345,-71.09
9 | 8,42.39,-71.105
10 | 9,42.38,-71.09
11 | 10,42.304917,-71.147374
12 | 11,42.373917,-70.067374
13 | 12,42.313917,-71.037374
14 | 13,42.40944,-71.1
15 | 14,42.41,-71.073
16 | 15,42.44,-71.15
17 | 16,42.48,-71.23
18 | 17,42.35,-71.05
19 | 18,42.33,-71.11
20 | 19,42.36,-71.25
21 | 20,42.413,-71.143
22 | 21,42.373917,-71.215
23 | 22,43.37,-71.085
24 | 23,43.39,-71.11
25 | 24,42.29,-71.13
26 | 25,42.31,-71.16
27 | 26,42.313,-71.135
28 | 27,42.297,-71.155
29 |
--------------------------------------------------------------------------------
/demo/demo_datasets/test_data/antennas.csv:
--------------------------------------------------------------------------------
1 | antenna_id,latitude,longitude
2 | 1,42.366944,-71.083611
3 | 2,42.386722,-71.138778
4 | 3,42.3604,-71.087374
5 | 4,42.353917,-71.105
6 | 5,42.36,-71.12
7 | 6,42.375,-71.1
8 | 7,42.345,-71.09
9 | 8,42.39,-71.105
10 | 9,42.38,-71.09
11 | 10,42.304917,-71.147374
12 | 11,42.373917,-70.067374
13 | 12,42.313917,-71.037374
14 | 13,42.40944,-71.1
15 | 14,42.41,-71.073
16 | 15,42.44,-71.15
17 | 16,42.48,-71.23
18 | 17,42.35,-71.05
19 | 18,42.33,-71.11
20 | 19,42.36,-71.25
21 | 20,42.413,-71.143
22 | 21,42.373917,-71.215
23 | 22,43.37,-71.085
24 | 23,43.39,-71.11
25 | 24,42.29,-71.13
26 | 25,42.31,-71.16
27 | 26,42.313,-71.135
28 | 27,42.297,-71.155
29 |
--------------------------------------------------------------------------------
/tests/performance_tests/test_IO.py:
--------------------------------------------------------------------------------
1 | import cProfile
2 | import cellyzer.io as io
3 |
4 | call_file_path = "../../demo/demo_datasets/long_data/calls_.csv"
5 | msg_file_path = "../../demo/demo_datasets/long_data/messages_.csv"
6 | cell_file_path = "../../demo/demo_datasets/long_data/antennas.csv"
7 |
8 |
9 | def test_read_call():
10 | io.read_call(call_file_path)
11 |
12 |
13 | def test_read_msg():
14 | io.read_msg(msg_file_path)
15 |
16 |
17 | def test_read_cell():
18 | io.read_cell(cell_file_path, call_dataset_obj=io.read_call(call_file_path))
19 |
20 |
21 | # cProfile run functions
22 | cProfile.run('test_read_call()')
23 | cProfile.run('test_read_msg()')
24 | cProfile.run('test_read_cell()')
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 Team Cellyzer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup
2 |
3 |
4 | def readme():
5 | with open('README.md') as f:
6 | README = f.read()
7 | return README
8 |
9 |
10 | setup(
11 | name="cellyzer",
12 | version="1.1.4",
13 | description="A CDR(Call Data Records) data analyzing library",
14 | long_description=readme(),
15 | long_description_content_type="text/markdown",
16 | url="https://github.com/anjuchamantha/cellyzer---CDR-data-analyzer",
17 | project_urls={
18 | "Documentation": "https://anjuchamantha.github.io/cellyzer---CDR-data-analyzer/",
19 | "Source Code": "https://github.com/anjuchamantha/cellyzer---CDR-data-analyzer",
20 | },
21 | author="Team Cellyzer",
22 | author_email="chamantha97anju@gmail.com",
23 | license="MIT",
24 | classifiers=[
25 | "License :: OSI Approved :: MIT License",
26 | "Intended Audience :: Science/Research",
27 | "Programming Language :: Python :: 3.7",
28 | ],
29 | packages=["cellyzer"],
30 | include_package_data=True,
31 | install_requires=[
32 | "xlrd == 1.2.0",
33 | "numpy == 1.18.2",
34 | "tabulate == 0.8.7",
35 | "datetime == 4.3",
36 | "networkx == 2.4",
37 | "matplotlib == 3.2.1",
38 | "folium == 0.10.1", 'IPython'
39 | ],
40 | )
41 |
--------------------------------------------------------------------------------
/demo/demo_cell.py:
--------------------------------------------------------------------------------
1 | """
2 | This is for manual testing the library
3 | """
4 |
5 | import cellyzer as cz
6 |
7 | call_file_path = "demo_datasets/long_data/calls_.csv"
8 | antenna_file_path = "demo_datasets/test_data/antennas.csv"
9 | callDataSet = cz.read_call(call_file_path)
10 | cz.read_cell(antenna_file_path, call_csv_path=None)
11 | antennaDataSet = cz.read_cell(antenna_file_path, call_dataset_obj=callDataSet, file_type='csv')
12 |
13 | # print antenna data set
14 | # cz.utils.print_dataset(antennaDataSet, name="Antenna Data set")
15 |
16 | # get a record of a given cell id
17 | # record = antennaDataSet.get_cell_records(cell_id=1)
18 | # print("Record of cell %s : %s \n" % (1, record.__dict__))
19 | #
20 | # print(">> population around cell")
21 | # population = antennaDataSet.get_population()
22 | # print(population)
23 | # cz.utils.tabulate_list_of_dictionaries(population)
24 | # cz.visualization.cell_population_visualization(population)
25 | #
26 | # print(">> Trip details of user : %s" % "8d27cf2694")
27 | # call_made_locations = antennaDataSet.get_trip_details("8d27cf2694", console_print=True, tabulate=True)
28 | # cz.visualization.trip_visualization(call_made_locations, notebook=False)
29 | #
30 | # test = callDataSet.get_records()
31 | # print(">> Unique users")
32 | # print(antennaDataSet.get_unique_users_around_cell(test))
33 | #
34 | # print(">> Is %s recorded in cell %s" % ("123", 10))
35 | # print(antennaDataSet.check_user_location_matches_cell(contact_no='123', cell_id=10))
36 |
--------------------------------------------------------------------------------
/demo/demo_message.py:
--------------------------------------------------------------------------------
1 | import cellyzer as cz
2 |
3 | msg_file_path = "demo_datasets/test_data/messages.csv"
4 | messageDataSet = cz.read_msg(msg_file_path)
5 |
6 | # Print the data set
7 | # cz.utils.print_dataset(messageDataSet, name="Message Dataset")
8 |
9 | # Get all the users in the data set
10 | # all_users = messageDataSet.get_all_users()
11 | # print("All Users : %s \n" % all_users)
12 | #
13 | search_user1 = "0041628436"
14 | search_user2 = "329233d117"
15 |
16 | # Get all the users connected to given user
17 | # connected_users = messageDataSet.get_connected_users("329233d117")
18 | # print("Users connected to %s : %s \n" % (search_user1, connected_users))
19 |
20 | # Get all the records of the given user/2 users
21 | user_record_list = messageDataSet.get_records(search_user1, search_user2)
22 | # cz.utils.print_record_lists(user_record_list)
23 |
24 | # make a new data set object with selected record objects from user records of the given 2 users
25 | user_message_dataset = cz.MessageDataSet(user_record_list)
26 | cz.utils.print_dataset(user_message_dataset, name="New Message DataSet obj : User Records of %s" % search_user1 + " & " + search_user2)
27 | #save dataset as a csv file
28 | cz.io.to_json(user_message_dataset,"records_of_2_users")
29 | # create a date time object with a timestamp string
30 | # date = cz.tools.get_datetime_from_timestamp("Mon Feb 11 07:08:49 +0000 1980")
31 |
32 | # print a connection matrix of all the users
33 | # messageDataSet.print_connection_matrix()
34 |
35 | # visualize the connections with the directions and number of connections
36 | # messageDataSet.visualize_connection_network()
37 |
38 | # top 3 close contacts of a given user
39 | # close_contacts = messageDataSet.get_close_contacts(search_user2, top_contact=3)
40 | # print(">> close contacts of %s :" % search_user1)
41 | # cz.utils.print_close_contacts(close_contacts)
42 | #
43 | # msg_connections = messageDataSet.get_connections()
44 | # print(">> All the connections %s :" % msg_connections)
45 | # print(msg_connections)
46 |
--------------------------------------------------------------------------------
/tests/unit_tests/test_MessageDataSet.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import cellyzer.core as core
3 | import cellyzer.io as io
4 |
5 |
6 | class TestMessageDataSet(unittest.TestCase):
7 |
8 | @classmethod
9 | def setUpClass(cls):
10 | # before all the tests
11 | cls.user1 = "0041628436"
12 | cls.user2 = "329233d117"
13 |
14 | cls.msgDataSet = core.MessageDataSet()
15 | msg_file_path = "../../demo/demo_datasets/test_data/messages.csv"
16 | cls.msgDataSet = io.read_msg(msg_file_path)
17 |
18 | @classmethod
19 | def tearDownClass(cls):
20 | # after all the tests
21 | pass
22 |
23 | def setUp(self):
24 | # run before each test
25 | pass
26 |
27 | def tearDown(self):
28 | # run after each test
29 | pass
30 |
31 | # functions
32 |
33 | def test_get_close_contacts(self):
34 | user1_result = {'bac412f897': 4, '329233d117': 2}
35 | self.assertEqual(self.msgDataSet.get_close_contacts(user=self.user1, top_contact=2), user1_result)
36 | self.assertEqual(self.msgDataSet.get_close_contacts(user=self.user1, top_contact='2'), user1_result)
37 |
38 | user2_result = {'bac412f897': 4, '0041628436': 2}
39 | self.assertEqual(self.msgDataSet.get_close_contacts(user=self.user2), user2_result)
40 |
41 | with self.assertRaises(TypeError):
42 | self.msgDataSet.get_close_contacts(12.3)
43 | self.msgDataSet.get_close_contacts([self.user1])
44 | self.msgDataSet.get_close_contacts({1})
45 | self.msgDataSet.get_close_contacts(None, None)
46 | self.msgDataSet.get_close_contacts(user=self.user1, top_contact=None)
47 | self.msgDataSet.get_close_contacts(user=self.user1, top_contact=12.3)
48 | self.msgDataSet.get_close_contacts(user=self.user1, top_contact=[1])
49 | self.msgDataSet.get_close_contacts(user=self.user1, top_contact={1})
50 |
51 |
52 | if __name__ == '__main__':
53 | unittest.main()
54 |
--------------------------------------------------------------------------------
/demo/demo_user.py:
--------------------------------------------------------------------------------
1 | """
2 | This is for manual testing the library
3 | """
4 |
5 | import cellyzer as cz
6 |
7 | call_file_path = "demo_datasets/test_data/calls.csv"
8 | # message_file_path = "demo_datasets/test_data/messages.csv"
9 | antenna_file_path = "demo_datasets/test_data/antennas.csv"
10 |
11 | callDataSet = cz.read_call(call_file_path)
12 | # messageDataSet = cz.read_msg(message_file_path)
13 | cellDataSet = cz.read_cell(antenna_file_path)
14 |
15 | user_number = "3e97992791"
16 | user2_number = "8d27cf2694"
17 | # date = cz.tools.get_date_from_timestamp("Mon Feb 11 07:08:49 +0000 1980")
18 | # print(date)
19 |
20 | user1 = cz.User(callDataSet=callDataSet, cellDataSet=cellDataSet, contact_no=user_number)
21 | user2 = cz.User(callDataSet=callDataSet, cellDataSet=cellDataSet, contact_no=user2_number)
22 | # filepath_to_save = "F:/SEMESTER 5/CS3202 - SE Project/maps/"
23 |
24 | location_home = user1.get_home_location()
25 | print('>> home location : ', location_home)
26 | home_cell_id = user1.get_home_location_related_cell_id()
27 | print(">> home location -> cell id : ", home_cell_id)
28 |
29 | location_office = user1.get_work_location()
30 | print('>> work location : ', location_office)
31 | officeplace_cell_id = user1.get_work_location_related_cell_id()
32 | print(">> work location -> cell id : ", officeplace_cell_id)
33 |
34 | cz.visualization.view_home_work_locations(home_location=location_home, work_location=location_office)
35 |
36 | user3_number = '329233d117'
37 | user3 = cz.User(callDataSet=callDataSet, cellDataSet=cellDataSet, contact_no=user3_number, work_start_time=15,
38 | work_end_time=22)
39 | ignored_call_details = user3.get_ignored_call_details()
40 | print(">> ignored calls details : ")
41 | print(ignored_call_details)
42 | cz.utils.tabulate_list_of_dictionaries(ignored_call_details)
43 |
44 |
45 | location_home = user3.get_home_location()
46 | print('>> home location : ', location_home)
47 | home_cell_id = user3.get_home_location_related_cell_id()
48 | print(">> home location -> cell id : ", home_cell_id)
49 |
50 | location_office = user3.get_work_location()
51 | print('>> work location : ', location_office)
52 | officeplace_cell_id = user3.get_work_location_related_cell_id()
53 | print(">> work location -> cell id : ", officeplace_cell_id)
54 |
--------------------------------------------------------------------------------
/cellyzer/matrix.py:
--------------------------------------------------------------------------------
1 | matrix_css = """
2 | table {
3 | position: relative;
4 | width: 1320px;
5 | background-color: #aaa;
6 | overflow: hidden;
7 | border-collapse: collapse;
8 | }
9 |
10 |
11 | /*thead*/
12 | thead {
13 | position: relative;
14 | width: 1320px;
15 | display: block; /*seperates the header from the body allowing it to be positioned*/
16 | overflow: visible;
17 | }
18 |
19 | thead th {
20 | background-color: #99a;
21 | min-width: 120px;
22 | height: 32px;
23 | border: 1px solid #222;
24 | }
25 |
26 | thead th:nth-child(1) {/*first cell in the header*/
27 | position: relative;
28 | display: block; /*seperates the first cell in the header from the header*/
29 | background-color: #88b;
30 | }
31 |
32 |
33 | /*tbody*/
34 | tbody {
35 | position: relative;
36 | display: block; /*seperates the tbody from the header*/
37 | height: 500px;
38 | width: 1320px;
39 | overflow: scroll;
40 | }
41 |
42 | tbody td {
43 | background-color: #bbc;
44 | min-width: 120px;
45 | border: 1px solid #222;
46 | }
47 |
48 | tbody tr td:nth-child(1) { /*the first cell in each tr*/
49 | position: relative;
50 | display: block; /*seperates the first column from the tbody*/
51 | height: 40px;
52 | background-color: #99a;
53 | }
54 | """
55 |
56 | matrix_js = """
57 | function scroll() {
58 | $('tbody').scroll(function(e) { //detect a scroll event on the tbody
59 | /*
60 | Setting the thead left value to the negative value of tbody.scrollLeft will make it track the movement
61 | of the tbody element. Setting an elements left value to that of the tbody.scrollLeft left makes it maintain it's relative position at the left of the table.
62 | */
63 | $('thead').css("left", -$("tbody").scrollLeft()); //fix the thead relative to the body scrolling
64 | $('thead th:nth-child(1)').css("left", $("tbody").scrollLeft()); //fix the first cell of the header
65 | $('tbody td:nth-child(1)').css("left", $("tbody").scrollLeft()); //fix the first column of tdbody
66 | });
67 | };
68 | """
69 |
70 | matrix_html_head = """
71 |
72 |
73 |
76 |
79 |
80 |
81 |
82 | Connection Matrix
83 |
84 | """.format(matrix_css, matrix_js)
85 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/demo_call_data_notebook-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "import cellyzer as cz"
10 | ]
11 | },
12 | {
13 | "cell_type": "code",
14 | "execution_count": 2,
15 | "metadata": {},
16 | "outputs": [
17 | {
18 | "name": "stdout",
19 | "output_type": "stream",
20 | "text": [
21 | "[x] Reading Message Data...\n",
22 | "[x] Objects creation successful\n",
23 | "\n"
24 | ]
25 | }
26 | ],
27 | "source": [
28 | "msg_file_path = \"../dataset/my_test_data/messages.csv\"\n",
29 | "messageDataSet = cz.read_msg(msg_file_path)\n",
30 | "cz.utils.print_dataset(messageDataSet,True)"
31 | ]
32 | },
33 | {
34 | "cell_type": "code",
35 | "execution_count": null,
36 | "metadata": {},
37 | "outputs": [],
38 | "source": [
39 | "all_users = messageDataSet.get_all_users()\n",
40 | "print(\"All Users : %s \\n\" % all_users)"
41 | ]
42 | },
43 | {
44 | "cell_type": "code",
45 | "execution_count": null,
46 | "metadata": {},
47 | "outputs": [],
48 | "source": [
49 | "connected_users = messageDataSet.get_connected_users(\"7610039694\")\n",
50 | "print(\"Users connected to 7610039694 : %s \\n\" % connected_users)"
51 | ]
52 | },
53 | {
54 | "cell_type": "code",
55 | "execution_count": null,
56 | "metadata": {},
57 | "outputs": [],
58 | "source": [
59 | "user_record_list = messageDataSet.get_records(\"7610039694\")\n",
60 | "user_message_dataset = cz.MessageDataSet(user_record_list)\n",
61 | "cz.utils.print_dataset_dict(user_message_dataset,True)"
62 | ]
63 | },
64 | {
65 | "cell_type": "code",
66 | "execution_count": null,
67 | "metadata": {},
68 | "outputs": [],
69 | "source": []
70 | },
71 | {
72 | "cell_type": "code",
73 | "execution_count": null,
74 | "metadata": {},
75 | "outputs": [],
76 | "source": []
77 | }
78 | ],
79 | "metadata": {
80 | "kernelspec": {
81 | "display_name": "Python 3.7.0 64-bit",
82 | "language": "python",
83 | "name": "python37064bite28e14d73ba543c1ba8f158838c934c3"
84 | },
85 | "language_info": {
86 | "codemirror_mode": {
87 | "name": "ipython",
88 | "version": 3
89 | },
90 | "file_extension": ".py",
91 | "mimetype": "text/x-python",
92 | "name": "python",
93 | "nbconvert_exporter": "python",
94 | "pygments_lexer": "ipython3",
95 | "version": "3.7.0"
96 | }
97 | },
98 | "nbformat": 4,
99 | "nbformat_minor": 2
100 | }
101 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CELLYZER
2 |
3 | **CELLYZER** is a python library for CDR(Call Detail Records) data analyzing. I majorly supports 3 type of datasets : Call, Message and Cell/Antenna
4 |
5 | This library can be used to easily get user records, connections between users, get population/traffic details using call and cell data etc. Also cellyzer can be used to visualize the population, user home/work locations, user trip/route identification etc.
6 |
7 | **CELLYZER GUI** can be used by even nun-coding people to interact with the library without writing a single line of code.
8 |
9 |
10 |
11 | ## Installation
12 |
13 | The source code is currently hosted on Github at https://github.com/anjuchamantha/cellyzer---CDR-data-analyzer.
14 |
15 | Binary installers for the latest released version are available at the Python package index:
16 |
17 | https://pypi.org/project/cellyzer/
18 |
19 | Use the package manager [pip](https://pip.pypa.io/en/stable/) to install cellyzer.
20 |
21 | ```
22 | pip install cellyzer
23 | ```
24 |
25 | or pip3
26 |
27 | ```
28 | pip3 install cellyzer
29 | ```
30 |
31 |
32 |
33 | ## Dependencies
34 |
35 | **CELLYZER** has some dependencies for calculations and data visualization
36 |
37 | - [xlrd](https://pypi.org/project/xlrd/) (1.2.0), [numpy](http://www.numpy.org/) (1.18.2), [tabulate](https://pypi.org/project/tabulate/) (0.8.7), [matplaotlib](https://matplotlib.org) (3.2.1), [networkx](https://networkx.github.io/) (2.4) and [datetime](https://pypi.org/project/DateTime/) (4.3)
38 | - [folium](https://python-visualization.github.io/folium/) (0.10.1) for visualization
39 |
40 | ## License
41 |
42 | The MIT License (MIT)
43 |
44 | Copyright (c) 2020 Team Cellyzer
45 |
46 | Permission is hereby granted, free of charge, to any person obtaining a copy
47 | of this software and associated documentation files (the "Software"), to deal
48 | in the Software without restriction, including without limitation the rights
49 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
50 | copies of the Software, and to permit persons to whom the Software is
51 | furnished to do so, subject to the following conditions:
52 |
53 | The above copyright notice and this permission notice shall be included in all
54 | copies or substantial portions of the Software.
55 |
56 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
57 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
58 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
59 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
60 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
61 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
62 | SOFTWARE.
63 |
64 |
65 |
66 | ## Documentation
67 |
68 | The official documentation is hosted on https://anjuchamantha.github.io/cellyzer---CDR-data-analyzer/. It includes a demo, a detailed reference for all functions, and guides on how to use **CELLYZER**.
69 |
70 |
--------------------------------------------------------------------------------
/demo/demo_calls.py:
--------------------------------------------------------------------------------
1 | """
2 | This is for manual testing the library
3 | """
4 |
5 | import cellyzer as cz
6 |
7 | call_file_path = "demo_datasets/test_data/calls.csv"
8 | # callDataSet = cz.read_call(call_file_path)
9 | cz.read_msg("demo_datasets/test_data/messages.csv")
10 | cz.read_cell("demo_datasets/test_data/antennas.csv")
11 |
12 | callDataSet = cz.read_call(file_path="demo_datasets/test_data/excel data/calls.xlsx", file_type="xlsx")
13 | cz.read_msg(file_path="demo_datasets/test_data/excel data/messages.xlsx", file_type="xlsx")
14 | cz.read_cell(file_path="demo_datasets/test_data/excel data/cell.xlsx", file_type="xlsx")
15 |
16 | cz.read_call(file_path="demo_datasets/test_data/json data/call.json", file_type="json")
17 | cz.read_msg(file_path="demo_datasets/test_data/json data/message.json", file_type="json")
18 | cz.read_cell(file_path="demo_datasets/test_data/json data/cell.json", file_type="json")
19 |
20 | # print(type(callDataSet).__name__)
21 | # cz.utils.print_dataset(callDataSet, name="Call Dataset")
22 | #
23 | # all_users_of_calls = callDataSet.get_all_users()
24 | # print(">> All Users in call dataSet : %s \n" % all_users_of_calls)
25 | #
26 | search_user_call_1 = "3e97992791"
27 | search_user_call_2 = "265034e175"
28 | search_user_call_3 = '329233d117'
29 | #
30 | # connected_users_calls = callDataSet.get_connected_users(search_user_call_1)
31 | # print(">> Users connected to %s : %s \n" % (search_user_call_1, connected_users_calls))
32 | #
33 | # user_call_record_list = callDataSet.get_records(search_user_call_1, search_user_call_2)
34 | # print(">> call records between %s and %s" % (search_user_call_1, search_user_call_2))
35 | # cz.utils.print_record_lists(user_call_record_list)
36 | #
37 | # user_call_dataset = cz.MessageDataSet(user_call_record_list)
38 | # cz.utils.print_dataset(user_call_dataset, name="User Records of %s" % search_user_call_1 + " " + search_user_call_2)
39 | #
40 | callDataSet.print_connection_matrix()
41 | #
42 | search_user_list = ["265034e175", "e98994c239", "f0860ea982"]
43 | callDataSet.visualize_connection_network(users=search_user_list, gui=True)
44 | #
45 | # close_contacts = callDataSet.get_close_contacts(search_user_call_3, top_contact=4)
46 | # print(">> close contacts of %s :" % search_user_call_1)
47 | # cz.utils.print_close_contacts(close_contacts)
48 | #
49 | active_time = callDataSet.get_most_active_time(search_user_call_1)
50 | print(">> most active times during day of %s - %s" % (search_user_call_1, active_time))
51 | cz.visualization.active_time_bar_chart(active_time, user=search_user_call_1)
52 | #
53 | # ignored_call_details = callDataSet.get_ignored_call_details(search_user_call_3)
54 | # print(">> Ignored calls details : ")
55 | # cz.utils.tabulate_list_of_dictionaries(ignored_call_details)
56 | #
57 | # call_records_around_cell = callDataSet.get_call_records_by_antenna_id(cell_id='1')
58 | # print(">> Number of call records around cell_id - %s = %s" % (1, len(call_records_around_cell)))
59 | #
60 | # call_connections = callDataSet.get_connections(users=search_user_list)
61 | # print(">> All the users connected to %s :" % search_user_list)
62 | # print(call_connections)
63 |
--------------------------------------------------------------------------------
/cellyzer/utils.py:
--------------------------------------------------------------------------------
1 | from collections import OrderedDict
2 |
3 | import tabulate
4 |
5 |
6 | def print_record_lists(records):
7 | for record in records:
8 | print(vars(record))
9 |
10 |
11 | def print_dataset(dataset_obj, notebook=False, name="Dataset", rows=None, summerize=False, head=5, tail=5):
12 | if rows is not None:
13 | if rows > 50:
14 | summerize = True
15 |
16 | # print a demo_datasets obj as a dictionary
17 | print("\n >>> %s :" % name)
18 | dict_list = []
19 | records = dataset_obj.get_records()
20 | len_records = len(records)
21 | if len_records > 50:
22 | summerize = True
23 | if summerize:
24 | for record in records[:head]:
25 | dict_list.append(record.__dict__)
26 | dict_list.append({})
27 | for record in records[-tail:]:
28 | dict_list.append(record.__dict__)
29 | else:
30 | for record in records:
31 | dict_list.append(record.__dict__)
32 | header = list(dict_list[0].keys())
33 | rows = []
34 | for i in range(0, len(dict_list)):
35 | values = list(dict_list[i].values())
36 | rows.append(values)
37 | if notebook:
38 | print(tabulate.tabulate(rows, header, tablefmt='html'))
39 | else:
40 | print(tabulate.tabulate(rows, header, tablefmt='pretty'))
41 | return [header, dict_list]
42 |
43 |
44 | def print_close_contacts(close_contact_dict):
45 | # print close contacts as a dictionary
46 | header = ["contact no", "no of interactions between users"]
47 | rows = []
48 | for key, value in close_contact_dict.items():
49 | row = [key, value]
50 | rows.append(row)
51 | print(tabulate.tabulate(rows, header, tablefmt='pretty'))
52 |
53 |
54 | def tabulate_list_of_dictionaries(dictionary_list):
55 | """
56 | tabulate the list of dictionaries
57 |
58 | :param dictionary_list: list
59 |
60 | :return: print table
61 | """
62 | if not dictionary_list:
63 | return None
64 | if type(dictionary_list) == list:
65 | header = []
66 | for item in dictionary_list[0].keys():
67 | header.append(item)
68 | rows = []
69 | for cell in dictionary_list:
70 | row = []
71 | for key in cell.keys():
72 | row.append(cell[key])
73 | rows.append(row)
74 |
75 | print(tabulate.tabulate(rows, header, tablefmt='pretty'))
76 |
77 |
78 | def flatten(d, parent_key='', separator='__'):
79 | """
80 | Flatten a nested dictionary.
81 |
82 | Parameters
83 | ----------
84 | d: dict_like
85 | Dictionary to flatten.
86 | parent_key: string, optional
87 | Concatenated names of the parent keys.
88 | separator: string, optional
89 | Separator between the names of the each key.
90 | The default separator is '_'.
91 |
92 | """
93 | items = []
94 | for k, v in d.items():
95 | new_key = parent_key + separator + k if parent_key else k
96 | if isinstance(v, (dict, OrderedDict)):
97 | items.extend(flatten(v, new_key, separator).items())
98 | else:
99 | items.append((new_key, v))
100 | return OrderedDict(items)
101 |
--------------------------------------------------------------------------------
/demo/demo_datasets/test_data/messages.csv:
--------------------------------------------------------------------------------
1 | user,other,direction,length,timestamp
2 | 7610039694,7684763671,Incoming,28,Wed Sep 15 19:01:54 +0100 2010
3 | 7641036117,7681546436,Incoming,7,Mon Feb 11 07:08:49 +0000 1980
4 | 7641036117,7681546436,Outgoing,6,Mon Feb 11 07:14:05 +0000 1980
5 | 7641036117,7981267897,Outgoing,41,Thu Sep 09 21:43:44 +0100 2010
6 | 7981267897,7784425582,Outgoing,75,Mon Jan 07 22:58:28 +0000 1980
7 | 7981267897,7784425582,Incoming,33,Thu Sep 09 18:53:25 +0100 2010
8 | 7981267897,7784425582,Outgoing,90,Thu Sep 09 18:59:35 +0100 2010
9 | 7981267897,7784425582,Incoming,30,Thu Sep 09 19:06:06 +0100 2010
10 | 7981267897,7784425582,Outgoing,112,Thu Sep 09 19:22:28 +0100 2010
11 | 7981267897,7784425582,Incoming,89,Thu Sep 09 19:24:50 +0100 2010
12 | 7981267897,7784425582,Outgoing,28,Thu Sep 09 19:26:17 +0100 2010
13 | 7981267897,7784425582,Incoming,19,Thu Sep 09 19:34:16 +0100 2010
14 | 7981267897,7784425582,Incoming,2,Thu Sep 09 19:35:07 +0100 2010
15 | 7981267897,7784425582,Outgoing,43,Thu Sep 09 19:35:45 +0100 2010
16 | 7981267897,7681546436,Incoming,19,Thu Sep 09 21:31:23 +0100 2010
17 | 7981267897,7681546436,Outgoing,20,Thu Sep 09 21:32:11 +0100 2010
18 | 7981267897,7681546436,Incoming,34,Thu Sep 09 21:33:45 +0100 2010
19 | 7981267897,7681546436,Outgoing,2,Thu Sep 09 21:34:14 +0100 2010
20 | 7981267897,7641036117,Incoming,41,Thu Sep 09 21:42:55 +0100 2010
21 | 7981267897,7784425582,Outgoing,23,Fri Sep 10 06:36:57 +0100 2010
22 | 7981267897,7784425582,Incoming,13,Fri Sep 10 06:38:38 +0100 2010
23 | 7981267897,7784425582,Outgoing,11,Fri Sep 10 06:39:10 +0100 2010
24 | 7981267897,7784425582,Incoming,15,Fri Sep 10 06:40:56 +0100 2010
25 | 7981267897,7033434266,Incoming,150,Fri Sep 10 12:23:21 +0100 2010
26 | 7981267897,7817341678,Incoming,45,Fri Sep 10 16:07:38 +0100 2010
27 | 7981267897,7541477895,Incoming,70,Fri Sep 10 16:33:49 +0100 2010
28 | 7981267897,7541477895,Outgoing,58,Fri Sep 10 16:36:07 +0100 2010
29 | 7981267897,7541477895,Incoming,9,Fri Sep 10 16:36:41 +0100 2010
30 | 7981267897,7784425582,Outgoing,14,Fri Sep 10 16:40:16 +0100 2010
31 | 7981267897,7641036117,Incoming,20,Fri Sep 10 16:47:21 +0100 2010
32 | 7981267897,7641036117,Outgoing,4,Fri Sep 10 16:47:45 +0100 2010
33 | 7981267897,7784425582,Incoming,100,Fri Sep 10 16:47:59 +0100 2010
34 | 7981267897,7784425582,Outgoing,49,Fri Sep 10 16:49:06 +0100 2010
35 | 7981267897,7784425582,Incoming,159,Fri Sep 10 16:52:51 +0100 2010
36 | 7981267897,7784425582,Outgoing,86,Fri Sep 10 16:55:14 +0100 2010
37 | 7981267897,7784425582,Incoming,57,Fri Sep 10 16:56:42 +0100 2010
38 | 7981267897,7784425582,Outgoing,59,Fri Sep 10 16:59:18 +0100 2010
39 | 7981267897,7784425582,Incoming,52,Fri Sep 10 17:00:37 +0100 2010
40 | 7981267897,7784425582,Outgoing,99,Fri Sep 10 17:02:45 +0100 2010
41 | 7981267897,7784425582,Incoming,82,Fri Sep 10 17:08:34 +0100 2010
42 | 7981267897,7784425582,Outgoing,71,Fri Sep 10 17:10:43 +0100 2010
43 | 7981267897,7784425582,Incoming,31,Fri Sep 10 17:29:15 +0100 2010
44 | 7981267897,7784425582,Outgoing,126,Fri Sep 10 17:31:56 +0100 2010
45 | 7981267897,7784425582,Incoming,36,Fri Sep 10 17:38:26 +0100 2010
46 | 7981267897,7784425582,Outgoing,159,Fri Sep 10 17:41:33 +0100 2010
47 | 7981267897,7784425582,Incoming,40,Fri Sep 10 17:43:14 +0100 2010
48 | 7981267897,7784425582,Outgoing,74,Fri Sep 10 17:47:08 +0100 2010
49 | 7981267897,7784425582,Incoming,29,Fri Sep 10 17:48:28 +0100 2010
50 | 7981267897,7784425582,Outgoing,149,Fri Sep 10 17:54:40 +0100 2010
51 |
--------------------------------------------------------------------------------
/cellyzer_gui/test/messages.csv:
--------------------------------------------------------------------------------
1 | user,other,direction,length,timestamp
2 | 7610039694,7684763671,Incoming,28,Wed Sep 15 19:01:54 +0100 2010
3 | 7641036117,7681546436,Incoming,7,Mon Feb 11 07:08:49 +0000 1980
4 | 7641036117,7681546436,Outgoing,6,Mon Feb 11 07:14:05 +0000 1980
5 | 7641036117,7981267897,Outgoing,41,Thu Sep 09 21:43:44 +0100 2010
6 | 7981267897,7784425582,Outgoing,75,Mon Jan 07 22:58:28 +0000 1980
7 | 7981267897,7784425582,Incoming,33,Thu Sep 09 18:53:25 +0100 2010
8 | 7981267897,7784425582,Outgoing,90,Thu Sep 09 18:59:35 +0100 2010
9 | 7981267897,7784425582,Incoming,30,Thu Sep 09 19:06:06 +0100 2010
10 | 7981267897,7784425582,Outgoing,112,Thu Sep 09 19:22:28 +0100 2010
11 | 7981267897,7784425582,Incoming,89,Thu Sep 09 19:24:50 +0100 2010
12 | 7981267897,7784425582,Outgoing,28,Thu Sep 09 19:26:17 +0100 2010
13 | 7981267897,7784425582,Incoming,19,Thu Sep 09 19:34:16 +0100 2010
14 | 7981267897,7784425582,Incoming,2,Thu Sep 09 19:35:07 +0100 2010
15 | 7981267897,7784425582,Outgoing,43,Thu Sep 09 19:35:45 +0100 2010
16 | 7981267897,7681546436,Incoming,19,Thu Sep 09 21:31:23 +0100 2010
17 | 7981267897,7681546436,Outgoing,20,Thu Sep 09 21:32:11 +0100 2010
18 | 7981267897,7681546436,Incoming,34,Thu Sep 09 21:33:45 +0100 2010
19 | 7981267897,7681546436,Outgoing,2,Thu Sep 09 21:34:14 +0100 2010
20 | 7981267897,7641036117,Incoming,41,Thu Sep 09 21:42:55 +0100 2010
21 | 7981267897,7784425582,Outgoing,23,Fri Sep 10 06:36:57 +0100 2010
22 | 7981267897,7784425582,Incoming,13,Fri Sep 10 06:38:38 +0100 2010
23 | 7981267897,7784425582,Outgoing,11,Fri Sep 10 06:39:10 +0100 2010
24 | 7981267897,7784425582,Incoming,15,Fri Sep 10 06:40:56 +0100 2010
25 | 7981267897,7033434266,Incoming,150,Fri Sep 10 12:23:21 +0100 2010
26 | 7981267897,7817341678,Incoming,45,Fri Sep 10 16:07:38 +0100 2010
27 | 7981267897,7541477895,Incoming,70,Fri Sep 10 16:33:49 +0100 2010
28 | 7981267897,7541477895,Outgoing,58,Fri Sep 10 16:36:07 +0100 2010
29 | 7981267897,7541477895,Incoming,9,Fri Sep 10 16:36:41 +0100 2010
30 | 7981267897,7784425582,Outgoing,14,Fri Sep 10 16:40:16 +0100 2010
31 | 7981267897,7641036117,Incoming,20,Fri Sep 10 16:47:21 +0100 2010
32 | 7981267897,7641036117,Outgoing,4,Fri Sep 10 16:47:45 +0100 2010
33 | 7981267897,7784425582,Incoming,100,Fri Sep 10 16:47:59 +0100 2010
34 | 7981267897,7784425582,Outgoing,49,Fri Sep 10 16:49:06 +0100 2010
35 | 7981267897,7784425582,Incoming,159,Fri Sep 10 16:52:51 +0100 2010
36 | 7981267897,7784425582,Outgoing,86,Fri Sep 10 16:55:14 +0100 2010
37 | 7981267897,7784425582,Incoming,57,Fri Sep 10 16:56:42 +0100 2010
38 | 7981267897,7784425582,Outgoing,59,Fri Sep 10 16:59:18 +0100 2010
39 | 7981267897,7784425582,Incoming,52,Fri Sep 10 17:00:37 +0100 2010
40 | 7981267897,7784425582,Outgoing,99,Fri Sep 10 17:02:45 +0100 2010
41 | 7981267897,7784425582,Incoming,82,Fri Sep 10 17:08:34 +0100 2010
42 | 7981267897,7784425582,Outgoing,71,Fri Sep 10 17:10:43 +0100 2010
43 | 7981267897,7784425582,Incoming,31,Fri Sep 10 17:29:15 +0100 2010
44 | 7981267897,7784425582,Outgoing,126,Fri Sep 10 17:31:56 +0100 2010
45 | 7981267897,7784425582,Incoming,36,Fri Sep 10 17:38:26 +0100 2010
46 | 7981267897,7784425582,Outgoing,159,Fri Sep 10 17:41:33 +0100 2010
47 | 7981267897,7784425582,Incoming,40,Fri Sep 10 17:43:14 +0100 2010
48 | 7981267897,7784425582,Outgoing,74,Fri Sep 10 17:47:08 +0100 2010
49 | 7981267897,7784425582,Incoming,29,Fri Sep 10 17:48:28 +0100 2010
50 | 7981267897,7784425582,Outgoing,149,Fri Sep 10 17:54:40 +0100 2010
51 | ,,,,,
52 | ,,,,,
--------------------------------------------------------------------------------
/demo/demo_datasets/test_data/json data/cell.json:
--------------------------------------------------------------------------------
1 | {
2 | "cellrecords":[
3 | {
4 | "antenna_id":1,
5 | "latitude":42.366944,
6 | "longitude":-71.083611
7 | },
8 | {
9 | "antenna_id":2,
10 | "latitude":42.386722,
11 | "longitude":-71.138778
12 | },
13 | {
14 | "antenna_id":3,
15 | "latitude":42.3604,
16 | "longitude":-71.087374
17 | },
18 | {
19 | "antenna_id":4,
20 | "latitude":42.353917,
21 | "longitude":-71.105
22 | },
23 | {
24 | "antenna_id":5,
25 | "latitude":42.36,
26 | "longitude":-71.12
27 | },
28 | {
29 | "antenna_id":6,
30 | "latitude":42.375,
31 | "longitude":-71.1
32 | },
33 | {
34 | "antenna_id":7,
35 | "latitude":42.345,
36 | "longitude":-71.09
37 | },
38 | {
39 | "antenna_id":8,
40 | "latitude":42.39,
41 | "longitude":-71.105
42 | },
43 | {
44 | "antenna_id":9,
45 | "latitude":42.38,
46 | "longitude":-71.09
47 | },
48 | {
49 | "antenna_id":10,
50 | "latitude":42.304917,
51 | "longitude":-71.147374
52 | },
53 | {
54 | "antenna_id":11,
55 | "latitude":42.373917,
56 | "longitude":-70.067374
57 | },
58 | {
59 | "antenna_id":12,
60 | "latitude":42.313917,
61 | "longitude":-71.037374
62 | },
63 | {
64 | "antenna_id":13,
65 | "latitude":42.40944,
66 | "longitude":-71.1
67 | },
68 | {
69 | "antenna_id":14,
70 | "latitude":42.41,
71 | "longitude":-71.073
72 | },
73 | {
74 | "antenna_id":15,
75 | "latitude":42.44,
76 | "longitude":-71.15
77 | },
78 | {
79 | "antenna_id":16,
80 | "latitude":42.48,
81 | "longitude":-71.23
82 | },
83 | {
84 | "antenna_id":17,
85 | "latitude":42.35,
86 | "longitude":-71.05
87 | },
88 | {
89 | "antenna_id":18,
90 | "latitude":42.33,
91 | "longitude":-71.11
92 | },
93 | {
94 | "antenna_id":19,
95 | "latitude":42.36,
96 | "longitude":-71.25
97 | },
98 | {
99 | "antenna_id":20,
100 | "latitude":42.413,
101 | "longitude":-71.143
102 | },
103 | {
104 | "antenna_id":21,
105 | "latitude":42.373917,
106 | "longitude":-71.215
107 | },
108 | {
109 | "antenna_id":22,
110 | "latitude":43.37,
111 | "longitude":-71.085
112 | },
113 | {
114 | "antenna_id":23,
115 | "latitude":43.39,
116 | "longitude":-71.11
117 | },
118 | {
119 | "antenna_id":24,
120 | "latitude":42.29,
121 | "longitude":-71.13
122 | },
123 | {
124 | "antenna_id":25,
125 | "latitude":42.31,
126 | "longitude":-71.16
127 | },
128 | {
129 | "antenna_id":26,
130 | "latitude":42.313,
131 | "longitude":-71.135
132 | },
133 | {
134 | "antenna_id":27,
135 | "latitude":42.297,
136 | "longitude":-71.155
137 | }
138 | ]
139 | }
--------------------------------------------------------------------------------
/cellyzer_gui/test/calls.csv:
--------------------------------------------------------------------------------
1 | user,other,direction,duration,timestamp,antenna_id,cost
2 | 7610039694,7434677419,Incoming,211,Wed Sep 15 19:17:44 +0100 2010,2,8
3 | 7641036117,1666472054,Outgoing,31,Mon Feb 11 07:18:23 +0000 1980,10,2
4 | 7641036117,7371326239,Incoming,45,Mon Feb 11 07:45:42 +0000 1980,2,2
5 | 7641036117,7681546436,Outgoing,10,Mon Feb 11 08:04:42 +0000 1980,3,2
6 | 7641036117,7681546436,Outgoing,0,Mon Feb 11 08:05:31 +0000 1980,4,0
7 | 7641036117,7681546436,Incoming,0,Mon Feb 11 08:06:18 +0000 1980,5,0
8 | 7641036117,7981267897,Outgoing,0,Mon Feb 11 08:06:31 +0000 1980,6,0
9 | 7641036117,7588304495,Incoming,124,Thu Sep 09 19:35:37 +0100 2010,7,6
10 | 7981267897,7784425582,Outgoing,474,Thu Sep 09 18:43:44 +0100 2010,5,16
11 | 7981267897,7743039441,Missed,0,Thu Sep 09 19:51:30 +0100 2010,3,0
12 | 7981267897,7784425582,Outgoing,0,Thu Sep 09 20:57:55 +0100 2010,1,0
13 | 7981267897,7784425582,Outgoing,605,Fri Sep 10 20:17:00 +0100 2010,1,22
14 | 7981267897,7784425582,Outgoing,1,Sat Sep 11 16:44:56 +0100 2010,1,2
15 | 7981267897,7743039441,Outgoing,59,Sat Sep 11 17:00:59 +0100 2010,2,2
16 | 7981267897,7784425582,Outgoing,1201,Mon Sep 13 14:53:26 +0100 2010,3,42
17 | 7981267897,7641036117,Outgoing,2,Tue Sep 14 07:19:17 +0100 2010,1,2
18 | 7163185791,1850897526,Outgoing,0,Thu Sep 09 21:05:12 +0100 2010,10,0
19 | 7163185791,7066875066,Outgoing,0,Fri Sep 10 18:14:22 +0100 2010,2,0
20 | 7163185791,7066875066,Outgoing,0,Fri Sep 10 18:14:46 +0100 2010,2,0
21 | 7163185791,7691640598,Outgoing,0,Fri Sep 10 18:16:16 +0100 2010,2,0
22 | 7163185791,7691640598,Outgoing,0,Fri Sep 10 18:17:32 +0100 2010,2,0
23 | 7163185791,8704500768,Missed,0,Tue Sep 14 13:18:18 +0100 2010,2,0
24 | 7163185791,7187432175,Outgoing,39,Tue Sep 14 15:23:43 +0100 2010,2,2
25 | 7163185791,7187432175,Outgoing,3,Tue Sep 14 15:27:12 +0100 2010,2,2
26 | 7163185791,7230262224,Incoming,47,Tue Sep 14 15:28:16 +0100 2010,2,2
27 | 7163185791,7187432175,Outgoing,8,Tue Sep 14 15:55:01 +0100 2010,2,2
28 | 7163185791,8704500768,Missed,0,Wed Sep 15 11:52:36 +0100 2010,2,0
29 | 7163185791,8704500768,Missed,0,Wed Sep 15 12:34:27 +0100 2010,2,0
30 | 7163185791,7187432175,Outgoing,8,Wed Sep 15 15:54:26 +0100 2010,2,2
31 | 7110730864,7209670163,Outgoing,0,Thu Sep 09 18:16:47 +0100 2010,1,0
32 | 7110730864,7209670163,Missed,0,Thu Sep 09 18:37:05 +0100 2010,2,0
33 | 7110730864,7209670163,Missed,0,Thu Sep 09 19:03:05 +0100 2010,2,0
34 | 7110730864,4.88E+31,Outgoing,0,Thu Sep 09 20:02:16 +0100 2010,2,0
35 | 7110730864,7209670163,Missed,0,Thu Sep 09 20:57:51 +0100 2010,3,0
36 | 7110730864,4.88E+31,Outgoing,0,Thu Sep 09 22:07:39 +0100 2010,3,0
37 | 7110730864,4.88E+31,Outgoing,0,Thu Sep 09 22:08:08 +0100 2010,3,0
38 | 7110730864,7209670163,Outgoing,215,Thu Sep 09 22:12:01 +0100 2010,2,8
39 | 7110730864,452,Outgoing,41,Thu Sep 09 22:38:09 +0100 2010,2,2
40 | 7110730864,563,Outgoing,0,Thu Sep 09 23:02:56 +0100 2010,2,0
41 | 7110730864,7501874156,Outgoing,0,Thu Sep 09 23:18:13 +0100 2010,2,0
42 | 7110730864,7784425582,Outgoing,0,Thu Sep 09 23:21:05 +0100 2010,2,0
43 | 7110730864,452,Outgoing,4,Thu Sep 09 23:28:24 +0100 2010,2,2
44 | 7110730864,452,Outgoing,52,Fri Sep 10 06:01:27 +0100 2010,1,2
45 | 7110730864,7209670163,Outgoing,0,Fri Sep 10 06:04:43 +0100 2010,2,0
46 | 7110730864,452,Outgoing,39,Fri Sep 10 07:45:52 +0100 2010,4,2
47 | 7110730864,7681546436,Missed,0,Fri Sep 10 07:53:09 +0100 2010,2,0
48 | 7110730864,7681546436,Outgoing,0,Fri Sep 10 07:54:02 +0100 2010,1,0
49 | 7110730864,7914559382,Outgoing,0,Fri Sep 10 11:15:49 +0100 2010,10,0
50 | 7110730864,1258345846,Missed,0,Fri Sep 10 19:35:57 +0100 2010,1,0
51 |
--------------------------------------------------------------------------------
/demo/demo_datasets/test_data/calls.csv:
--------------------------------------------------------------------------------
1 | user,other,direction,duration,timestamp,antenna_id,cost
2 | 7610039694,7434677419,Incoming,211,Wed Sep 15 19:17:44 +0100 2010,2,8
3 | 7641036117,1666472054,Outgoing,31,Mon Feb 11 07:18:23 +0000 1980,10,2
4 | 7641036117,7371326239,Incoming,45,Mon Feb 11 07:45:42 +0000 1980,2,2
5 | 7641036117,7681546436,Outgoing,10,Mon Feb 11 08:04:42 +0000 1980,3,2
6 | 7641036117,7681546436,Outgoing,0,Mon Feb 11 08:05:31 +0000 1980,4,0
7 | 7641036117,7681546436,Incoming,0,Mon Feb 11 08:06:18 +0000 1980,5,0
8 | 7641036117,7981267897,Outgoing,0,Mon Feb 11 08:06:31 +0000 1980,6,0
9 | 7641036117,7588304495,Incoming,124,Thu Sep 09 19:35:37 +0100 2010,7,6
10 | 7981267897,7784425582,Outgoing,474,Thu Sep 09 18:43:44 +0100 2010,5,16
11 | 7981267897,7743039441,Missed,0,Thu Sep 09 19:51:30 +0100 2010,3,0
12 | 7981267897,7784425582,Outgoing,0,Thu Sep 09 20:57:55 +0100 2010,1,0
13 | 7981267897,7784425582,Outgoing,605,Fri Sep 10 20:17:00 +0100 2010,1,22
14 | 7981267897,7784425582,Outgoing,1,Sat Sep 11 16:44:56 +0100 2010,1,2
15 | 7981267897,7743039441,Outgoing,59,Sat Sep 11 17:00:59 +0100 2010,2,2
16 | 7981267897,7784425582,Outgoing,1201,Mon Sep 13 14:53:26 +0100 2010,3,42
17 | 7981267897,7641036117,Outgoing,2,Tue Sep 14 07:19:17 +0100 2010,1,2
18 | 7163185791,1850897526,Outgoing,0,Thu Sep 09 21:05:12 +0100 2010,10,0
19 | 7163185791,7066875066,Outgoing,0,Fri Sep 10 18:14:22 +0100 2010,2,0
20 | 7163185791,7066875066,Outgoing,0,Fri Sep 10 18:14:46 +0100 2010,2,0
21 | 7163185791,7691640598,Outgoing,0,Fri Sep 10 18:16:16 +0100 2010,2,0
22 | 7163185791,7691640598,Outgoing,0,Fri Sep 10 18:17:32 +0100 2010,2,0
23 | 7163185791,8704500768,Missed,0,Tue Sep 14 13:18:18 +0100 2010,2,0
24 | 7163185791,7187432175,Outgoing,39,Tue Sep 14 15:23:43 +0100 2010,2,2
25 | 7163185791,7187432175,Outgoing,3,Tue Sep 14 15:27:12 +0100 2010,2,2
26 | 7163185791,7230262224,Incoming,47,Tue Sep 14 15:28:16 +0100 2010,2,2
27 | 7163185791,7187432175,Outgoing,8,Tue Sep 14 15:55:01 +0100 2010,2,2
28 | 7163185791,8704500768,Missed,0,Wed Sep 15 11:52:36 +0100 2010,2,0
29 | 7163185791,8704500768,Missed,0,Wed Sep 15 12:34:27 +0100 2010,2,0
30 | 7163185791,7187432175,Outgoing,8,Wed Sep 15 15:54:26 +0100 2010,2,2
31 | 7110730864,7209670163,Outgoing,0,Thu Sep 09 18:16:47 +0100 2010,1,0
32 | 7110730864,7209670163,Missed,0,Thu Sep 09 18:37:05 +0100 2010,2,0
33 | 7110730864,7209670163,Missed,0,Thu Sep 09 19:03:05 +0100 2010,2,0
34 | 7110730864,4.88E+31,Outgoing,0,Thu Sep 09 20:02:16 +0100 2010,2,0
35 | 7110730864,7209670163,Missed,0,Thu Sep 09 20:57:51 +0100 2010,3,0
36 | 7110730864,4.88E+31,Outgoing,0,Thu Sep 09 22:07:39 +0100 2010,3,0
37 | 7110730864,4.88E+31,Outgoing,0,Thu Sep 09 22:08:08 +0100 2010,3,0
38 | 7110730864,7209670163,Outgoing,215,Thu Sep 09 22:12:01 +0100 2010,2,8
39 | 7110730864,452,Outgoing,41,Thu Sep 09 22:38:09 +0100 2010,2,2
40 | 7110730864,563,Outgoing,0,Thu Sep 09 23:02:56 +0100 2010,2,0
41 | 7110730864,7501874156,Outgoing,0,Thu Sep 09 23:18:13 +0100 2010,2,0
42 | 7110730864,7784425582,Outgoing,0,Thu Sep 09 23:21:05 +0100 2010,2,0
43 | 7110730864,452,Outgoing,4,Thu Sep 09 23:28:24 +0100 2010,2,2
44 | 7110730864,452,Outgoing,52,Fri Sep 10 06:01:27 +0100 2010,1,2
45 | 7110730864,7209670163,Outgoing,0,Fri Sep 10 06:04:43 +0100 2010,2,0
46 | 7110730864,452,Outgoing,39,Fri Sep 10 07:45:52 +0100 2010,4,2
47 | 7110730864,7681546436,Missed,0,Fri Sep 10 07:53:09 +0100 2010,2,0
48 | 7110730864,7681546436,Outgoing,0,Fri Sep 10 07:54:02 +0100 2010,1,0
49 | 7110730864,7914559382,Outgoing,0,Fri Sep 10 11:15:49 +0100 2010,10,0
50 | 7110730864,1258345846,Missed,0,Fri Sep 10 19:35:57 +0100 2010,1,0
51 |
--------------------------------------------------------------------------------
/cellyzer.egg-info/PKG-INFO:
--------------------------------------------------------------------------------
1 | Metadata-Version: 2.1
2 | Name: cellyzer
3 | Version: 1.1.4
4 | Summary: A CDR(Call Data Records) data analyzing library
5 | Home-page: https://anjuchamantha.github.io/cellyzer---CDR-data-analyzer/
6 | Author: Team Cellyzer
7 | Author-email: chamantha97anju@gmail.com
8 | License: MIT
9 | Description: # CELLYZER
10 |
11 | **CELLYZER** is a python library for CDR(Call Detail Records) data analyzing. I majorly supports 3 type of datasets : Call, Message and Cell/Antenna
12 |
13 | This library can be used to easily get user records, connections between users, get population/traffic details using call and cell data etc. Also cellyzer can be used to visualize the population, user home/work locations, user trip/route identification etc.
14 |
15 | **CELLYZER GUI** can be used by even nun-coding people to interact with the library without writing a single line of code.
16 |
17 |
18 |
19 | ## Installation
20 |
21 | The source code is currently hosted on Github at https://github.com/anjuchamantha/cellyzer---CDR-data-analyzer.
22 |
23 | Binary installers for the latest released version are available at the Python package index:
24 |
25 | https://pypi.org/project/cellyzer/
26 |
27 | Use the package manager [pip](https://pip.pypa.io/en/stable/) to install cellyzer.
28 |
29 | ```
30 | pip install cellyzer
31 | ```
32 |
33 | or pip3
34 |
35 | ```
36 | pip3 install cellyzer
37 | ```
38 |
39 |
40 |
41 | ## Dependencies
42 |
43 | **CELLYZER** has some dependencies for calculations and data visualization
44 |
45 | - [xlrd](https://pypi.org/project/xlrd/) (1.2.0), [numpy](http://www.numpy.org/) (1.18.2), [tabulate](https://pypi.org/project/tabulate/) (0.8.7), [matplaotlib](https://matplotlib.org) (3.2.1), [networkx](https://networkx.github.io/) (2.4) and [datetime](https://pypi.org/project/DateTime/) (4.3)
46 | - [folium](https://python-visualization.github.io/folium/) (0.10.1) for visualization
47 |
48 | ## License
49 |
50 | The MIT License (MIT)
51 |
52 | Copyright (c) 2020 Team Cellyzer
53 |
54 | Permission is hereby granted, free of charge, to any person obtaining a copy
55 | of this software and associated documentation files (the "Software"), to deal
56 | in the Software without restriction, including without limitation the rights
57 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
58 | copies of the Software, and to permit persons to whom the Software is
59 | furnished to do so, subject to the following conditions:
60 |
61 | The above copyright notice and this permission notice shall be included in all
62 | copies or substantial portions of the Software.
63 |
64 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
66 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
67 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
68 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
69 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
70 | SOFTWARE.
71 |
72 |
73 |
74 | ## Documentation
75 |
76 | The official documentation is hosted on https://github.com/anjuchamantha/cellyzer---CDR-data-analyzer. It includes a demo, a detailed reference for all functions, and guides on how to use **CELLYZER**.
77 |
78 |
79 | Platform: UNKNOWN
80 | Classifier: License :: OSI Approved :: MIT License
81 | Classifier: Intended Audience :: Science/Research
82 | Classifier: Programming Language :: Python :: 3.7
83 | Description-Content-Type: text/markdown
84 |
--------------------------------------------------------------------------------
/tests/unit_tests/test_CallDataSet.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import cellyzer.core as core
3 | import cellyzer.io as io
4 |
5 |
6 | class TestCallDataSet(unittest.TestCase):
7 |
8 | @classmethod
9 | def setUpClass(cls):
10 | # before all the tests
11 | cls.user1 = "3e97992791"
12 | cls.user2 = "265034e175"
13 | cls.user3 = '329233d117'
14 | cls.callDataSet = core.CallDataSet()
15 | call_file_path = "../../demo/demo_datasets/test_data/calls.csv"
16 | cls.callDataSet = io.read_call(call_file_path)
17 |
18 | @classmethod
19 | def tearDownClass(cls):
20 | # after all the tests
21 | pass
22 |
23 | def setUp(self):
24 | # run before each test
25 | pass
26 |
27 | def tearDown(self):
28 | # run after each test
29 | pass
30 |
31 | # functions
32 |
33 | def test_get_most_active_time(self):
34 | user1_result = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 1, 12: 1, 13: 1, 14: 0,
35 | 15: 5, 16: 0, 17: 0, 18: 4, 19: 0, 20: 0, 21: 1, 22: 0, 23: 0}
36 | self.assertEqual(self.callDataSet.get_most_active_time(user=self.user1), user1_result)
37 |
38 | user2_result = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0,
39 | 15: 4, 16: 0, 17: 0, 18: 0, 19: 0, 20: 0, 21: 0, 22: 0, 23: 0}
40 | self.assertEqual(self.callDataSet.get_most_active_time(user=self.user2), user2_result)
41 |
42 | user3_result = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 3, 8: 4, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0, 14: 0,
43 | 15: 0, 16: 0, 17: 0, 18: 0, 19: 1, 20: 0, 21: 0, 22: 0, 23: 0}
44 | self.assertEqual(self.callDataSet.get_most_active_time(user=self.user3), user3_result)
45 |
46 | with self.assertRaises(TypeError):
47 | self.callDataSet.get_most_active_time(12.34)
48 | self.callDataSet.get_most_active_time([self.user1])
49 | self.callDataSet.get_most_active_time({})
50 |
51 | def test_get_close_contacts(self):
52 | user1_result = {'265034e175': 4, '5973bd0224': 1}
53 | self.assertEqual(self.callDataSet.get_close_contacts(user=self.user1, top_contact=2), user1_result)
54 |
55 | user2_result = {'3e97992791': 4}
56 | self.assertEqual(self.callDataSet.get_close_contacts(user=self.user2), user2_result)
57 |
58 | user3_result = {'6cfc4bd054': 1, 'e98994c239': 1, '0041628436': 1, 'bac412f897': 1}
59 | self.assertEqual(self.callDataSet.get_close_contacts(user=self.user3, top_contact='4'), user3_result)
60 |
61 | with self.assertRaises(TypeError):
62 | self.callDataSet.get_close_contacts(12.3)
63 | self.callDataSet.get_close_contacts([self.user1])
64 | self.callDataSet.get_close_contacts({})
65 | self.callDataSet.get_close_contacts(None, None)
66 | self.callDataSet.get_close_contacts(user=self.user1, top_contact=None)
67 | self.callDataSet.get_close_contacts(user=self.user1, top_contact=12.3)
68 | self.callDataSet.get_close_contacts(user=self.user1, top_contact='1')
69 | self.callDataSet.get_close_contacts(user=self.user1, top_contact=[1])
70 | self.callDataSet.get_close_contacts(user=self.user1, top_contact={1})
71 |
72 | def test_get_call_records_by_antenna_id(self):
73 | cell1_result = 8
74 | self.assertEqual(len(self.callDataSet.get_call_records_by_antenna_id(cell_id=1)), cell1_result)
75 |
76 | cell2_result = 26
77 | self.assertEqual(len(self.callDataSet.get_call_records_by_antenna_id(cell_id=2)), cell2_result)
78 |
79 | self.assertEqual(len(self.callDataSet.get_call_records_by_antenna_id(cell_id=20)), 0)
80 |
81 | def test_get_ignored_call_details(self):
82 | self.assertEqual(self.callDataSet.get_ignored_call_details(user=self.user1), [])
83 | self.assertEqual(self.callDataSet.get_ignored_call_details(user=self.user2), [])
84 |
85 | user3_result = [{'other user': '0041628436', 'date': '11-02-1980', 'time stamp': '08:06:18', 'cell ID': '5'}]
86 | self.assertEqual(self.callDataSet.get_ignored_call_details(user=self.user3), user3_result)
87 |
88 | with self.assertRaises(TypeError):
89 | self.callDataSet.get_ignored_call_details(12.3)
90 | self.callDataSet.get_ignored_call_details([self.user1])
91 | self.callDataSet.get_ignored_call_details({})
92 |
93 |
94 | if __name__ == '__main__':
95 | unittest.main()
96 |
--------------------------------------------------------------------------------
/cellyzer_gui/outputs/map.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
25 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/tests/performance_tests/test_CORE.py:
--------------------------------------------------------------------------------
1 | import cProfile
2 | import cellyzer.io as io
3 | import cellyzer.core as core
4 |
5 | # setup
6 | user1 = "8d27cf2694"
7 | user2 = "373a4fb419"
8 | user3 = '329233d117'
9 | user4 = "d235863694"
10 | user5 = "e59cd92671"
11 |
12 | call_file_path = "../../demo/demo_datasets/long_data/calls_.csv"
13 | callDataSet = io.read_call(call_file_path)
14 |
15 | msg_file_path = "../../demo/demo_datasets/long_data/messages_.csv"
16 | msgDataSet = io.read_msg(msg_file_path)
17 |
18 | cell_file_path = "../../demo/demo_datasets/long_data/antennas.csv"
19 | cellDataSet = io.read_cell(cell_file_path, call_dataset_obj=callDataSet)
20 |
21 | user1_obj = core.User(callDataSet=callDataSet, cellDataSet=cellDataSet, contact_no=user1)
22 | user2_obj = core.User(callDataSet=callDataSet, cellDataSet=cellDataSet, contact_no=user2)
23 | user3_obj = core.User(callDataSet=callDataSet, cellDataSet=cellDataSet, contact_no=user3)
24 |
25 |
26 | # ############################# callMessage Data set functions
27 | def test_get_records():
28 | callDataSet.get_records()
29 |
30 |
31 | def test_get_all_users():
32 | callDataSet.get_all_users()
33 |
34 |
35 | def test_get_connected_users():
36 | callDataSet.get_connected_users(user1)
37 |
38 |
39 | def test_get_connections():
40 | callDataSet.get_connections(allow_duplicates=True)
41 |
42 |
43 | # ############################## call Data set Functions
44 | def test_get_most_active_time():
45 | callDataSet.get_most_active_time(user=user1)
46 |
47 |
48 | def test_get_close_contacts():
49 | callDataSet.get_close_contacts(user=user1, top_contact=2)
50 |
51 |
52 | def test_get_call_records_by_antenna_id():
53 | callDataSet.get_call_records_by_antenna_id(cell_id=1)
54 |
55 |
56 | def test_get_ignored_call_details():
57 | callDataSet.get_ignored_call_details(user=user1)
58 |
59 |
60 | # ################################### Message Data set functions
61 | def test_msg_get_close_contacts():
62 | msgDataSet.get_close_contacts(user=user4, top_contact=2)
63 |
64 |
65 | # ################################## Cell data set functions
66 | def test_get_cell_records():
67 | cellDataSet.get_cell_records()
68 |
69 |
70 | def test_get_location():
71 | cellDataSet.get_location(1)
72 |
73 |
74 | def test_get_population():
75 | cellDataSet.get_population()
76 |
77 |
78 | def test_get_unique_users_around_cell():
79 | cellDataSet.get_unique_users_around_cell(callDataSet.get_records())
80 |
81 |
82 | def test_check_user_location_matches_cell():
83 | cellDataSet.check_user_location_matches_cell(user1, 2)
84 |
85 |
86 | def test_get_trip_details():
87 | cellDataSet.get_trip_details(user1)
88 |
89 |
90 | # ################################## User functions
91 | def test_get_contact_no():
92 | user1_obj.get_contact_no()
93 |
94 |
95 | def test_compute_home():
96 | user1_obj.compute_home()
97 |
98 |
99 | def test_compute_work_location():
100 | user1_obj.compute_work_location()
101 |
102 |
103 | def test_check_timestamp_for_home():
104 | user1_records = callDataSet.get_records(user1)
105 | user1_obj.check_timestamp_for_home(user1_records[0])
106 |
107 |
108 | def test_get_home_location():
109 | user1_obj.get_home_location()
110 |
111 |
112 | def test_get_work_location():
113 | user1_obj.get_work_location()
114 |
115 |
116 | def test_get_home_location_related_cell_id():
117 | user1_obj.get_home_location_related_cell_id()
118 |
119 |
120 | def test_get_work_location_related_cell_id():
121 | user1_obj.get_work_location_related_cell_id()
122 |
123 |
124 | def test_user_get_ignored_call_details():
125 | user1_obj.get_ignored_call_details()
126 |
127 |
128 | # ################################################################ cProfile run
129 | cProfile.run('test_get_records()')
130 | cProfile.run('test_get_all_users()')
131 | cProfile.run('test_get_connected_users()')
132 | cProfile.run('test_get_connections()')
133 |
134 | cProfile.run('test_get_most_active_time()')
135 | cProfile.run('test_get_close_contacts()')
136 | cProfile.run('test_get_call_records_by_antenna_id()')
137 | cProfile.run('test_get_ignored_call_details()')
138 |
139 | cProfile.run('test_msg_get_close_contacts()')
140 |
141 | cProfile.run('test_get_cell_records()')
142 | cProfile.run('test_get_location()')
143 | cProfile.run('test_get_population()')
144 | cProfile.run('test_get_unique_users_around_cell()')
145 | cProfile.run('test_check_user_location_matches_cell()')
146 | cProfile.run('test_get_trip_details()')
147 |
148 | cProfile.run('test_get_contact_no()')
149 | cProfile.run('test_compute_home()')
150 | cProfile.run('test_compute_work_location()')
151 | cProfile.run('test_check_timestamp_for_home()')
152 | cProfile.run('test_get_home_location()')
153 | cProfile.run('test_get_work_location()')
154 | cProfile.run('test_get_home_location_related_cell_id()')
155 | cProfile.run('test_get_work_location_related_cell_id()')
156 | cProfile.run('test_get_ignored_call_details()')
157 |
--------------------------------------------------------------------------------
/tests/unit_tests/test_user.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import cellyzer.core as core
3 | import cellyzer.io as io
4 |
5 |
6 | class TestUser(unittest.TestCase):
7 |
8 | @classmethod
9 | def setUpClass(cls):
10 | # before all the tests
11 | cls.user1_contact_no = "3e97992791"
12 | cls.user2_contact_no = "8d27cf2694"
13 | cls.user3_contact_no = '329233d117'
14 |
15 | cls.callDataSet = core.CallDataSet()
16 | call_file_path = "../../demo/demo_datasets/test_data/calls.csv"
17 | cls.callDataSet = io.read_call(call_file_path)
18 |
19 | cell_file_path = "../../demo/demo_datasets/test_data/antennas.csv"
20 | # cls.cellDataSet = core.CellDataSet( )
21 | cls.cellDataSet = io.read_cell(cell_file_path, call_dataset_obj=cls.callDataSet)
22 |
23 | cls.user1 = core.User(callDataSet=cls.callDataSet, cellDataSet=cls.cellDataSet, contact_no=cls.user1_contact_no)
24 | cls.user2 = core.User(callDataSet=cls.callDataSet, cellDataSet=cls.cellDataSet, contact_no=cls.user2_contact_no)
25 | cls.user3 = core.User(callDataSet=cls.callDataSet, cellDataSet=cls.cellDataSet, contact_no=cls.user3_contact_no)
26 | cls.user3_new = core.User(callDataSet=cls.callDataSet, cellDataSet=cls.cellDataSet,
27 | contact_no=cls.user3_contact_no, work_start_time=15, work_end_time=22)
28 |
29 | @classmethod
30 | def tearDownClass(cls):
31 | # after all the tests
32 | pass
33 |
34 | def setUp(self):
35 | # run before each test
36 | pass
37 |
38 | def tearDown(self):
39 | # run after each test
40 | pass
41 |
42 | # functions
43 |
44 | def test_get_contact_no(self):
45 | self.assertEqual(self.user1.get_contact_no(), self.user1_contact_no)
46 | self.assertEqual(self.user2.get_contact_no(), self.user2_contact_no)
47 | self.assertEqual(type(self.user2.get_contact_no()), str)
48 |
49 | def test_compute_home(self):
50 | self.assertEqual(self.user1.compute_home(), [42.304917, -71.147374])
51 | self.assertEqual(self.user2.compute_home(), [42.386722, -71.138778])
52 | self.assertEqual(self.user3.compute_home(), [42.304917, -71.147374])
53 | self.assertEqual(self.user3_new.compute_home(), [42.304917, -71.147374])
54 |
55 | def test_compute_work_location(self):
56 | self.assertEqual(self.user1.compute_work_location(), [42.386722, -71.138778])
57 | self.assertEqual(self.user2.compute_work_location(), [42.386722, -71.138778])
58 | self.assertEqual(self.user3.compute_work_location(), [42.3604, -71.087374])
59 | self.assertEqual(self.user3_new.compute_work_location(), [42.345, -71.09])
60 |
61 | def test_check_timestamp_for_home(self):
62 | user1_records = self.callDataSet.get_records(self.user1_contact_no)
63 | self.assertEqual(self.user1.check_timestamp_for_home(user1_records[0]), True)
64 | self.assertEqual(self.user1.check_timestamp_for_home(user1_records[1]), False)
65 | self.assertEqual(self.user1.check_timestamp_for_home(user1_records[2]), False)
66 |
67 | def test_get_home_location(self):
68 | self.assertEqual(self.user1.get_home_location(), [42.304917, -71.147374])
69 | self.assertEqual(self.user2.get_home_location(), [42.386722, -71.138778])
70 | self.assertEqual(self.user3.get_home_location(), [42.304917, -71.147374])
71 | self.assertEqual(self.user3_new.get_home_location(), [42.304917, -71.147374])
72 |
73 | def test_get_work_location(self):
74 | self.assertEqual(self.user1.get_work_location(), [42.386722, -71.138778])
75 | self.assertEqual(self.user2.get_work_location(), [42.386722, -71.138778])
76 | self.assertEqual(self.user3.get_work_location(), [42.3604, -71.087374])
77 | self.assertEqual(self.user3_new.get_work_location(), [42.345, -71.09])
78 |
79 | def test_get_home_location_related_cell_id(self):
80 | self.assertEqual(self.user1.get_home_location_related_cell_id(), "10")
81 | self.assertEqual(self.user2.get_home_location_related_cell_id(), "2")
82 | self.assertEqual(self.user3.get_home_location_related_cell_id(), "10")
83 | self.assertEqual(self.user3_new.get_home_location_related_cell_id(), "10")
84 |
85 | def test_get_work_location_related_cell_id(self):
86 | self.assertEqual(self.user1.get_work_location_related_cell_id(), "2")
87 | self.assertEqual(self.user2.get_work_location_related_cell_id(), "2")
88 | self.assertEqual(self.user3.get_work_location_related_cell_id(), "3")
89 | self.assertEqual(self.user3_new.get_work_location_related_cell_id(), "7")
90 |
91 | def test_get_ignored_call_details(self):
92 | self.assertEqual(self.user1.get_ignored_call_details(), [])
93 |
94 | user3_result = [{'other user': '0041628436', 'date': '11-02-1980', 'time stamp': '08:06:18', 'cell ID': '5'}]
95 | self.assertEqual(self.user3.get_ignored_call_details(), user3_result)
96 |
97 |
98 | if __name__ == '__main__':
99 | unittest.main()
100 |
--------------------------------------------------------------------------------
/tests/unit_tests/test_CallMessageDataSet.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import cellyzer.core as core
3 | import cellyzer.io as io
4 |
5 |
6 | class TestCallMessageDataSet(unittest.TestCase):
7 |
8 | @classmethod
9 | def setUpClass(cls):
10 | # before all the tests
11 | cls.user1 = "3e97992791"
12 | cls.user2 = "265034e175"
13 | cls.user3 = '329233d117'
14 |
15 | cls.callDataSet = core.CallDataSet()
16 | call_file_path = "../../demo/demo_datasets/test_data/calls.csv"
17 | cls.callDataSet = io.read_call(call_file_path)
18 |
19 | cls.msgDataSet = core.MessageDataSet()
20 | msg_file_path = "../../demo/demo_datasets/test_data/messages.csv"
21 | cls.msgDataSet = io.read_msg(msg_file_path)
22 |
23 | @classmethod
24 | def tearDownClass(cls):
25 | # after all the tests
26 | pass
27 |
28 | def setUp(self):
29 | # run before each test
30 | pass
31 |
32 | def tearDown(self):
33 | # run after each test
34 | pass
35 |
36 | # functions
37 |
38 | def test_get_records(self):
39 | self.assertEqual(len(self.callDataSet.get_records()), 49)
40 | self.assertEqual(len(self.callDataSet.get_records(self.user1)), 13)
41 | self.assertEqual(len(self.msgDataSet.get_records(123)), 0)
42 | self.assertEqual(len(self.callDataSet.get_records(self.user1, self.user2)), 4)
43 |
44 | with self.assertRaises(TypeError):
45 | self.callDataSet.get_records(user1=12.3)
46 | self.msgDataSet.get_records(user1=[self.user1])
47 | self.callDataSet.get_records(user2={self.user2})
48 |
49 | def test_get_all_users(self):
50 | call_users = ['8d27cf2694', '373a4fb419', '329233d117', '6cfc4bd054', 'e98994c239', '0041628436', 'bac412f897',
51 | '11fb537495', '322692e582', 'c21b973441', '3e97992791', '64e7321526', '2bc2488066', '2f78602598',
52 | '377415d768', '265034e175', '5973bd0224', '7331c02864', 'f23eb82163', '2914c2d+31', 'e967db9452',
53 | 'ca69f5a563', '380c65b156', '0c47c9c382', '1ed77db846']
54 |
55 | self.assertEqual(self.callDataSet.get_all_users(), call_users)
56 |
57 | msg_users = ['8d27cf2694', '78c4ca6671', '329233d117', '0041628436', 'bac412f897', '322692e582', 'e1ba3ba266',
58 | 'ae578bf678', '30b785e895']
59 | self.assertEqual(self.msgDataSet.get_all_users(), msg_users)
60 |
61 | def test_get_connected_users(self):
62 | user1_connections_calls = ['64e7321526', '2bc2488066', '2f78602598', '377415d768', '265034e175', '5973bd0224']
63 | self.assertEqual(self.callDataSet.get_connected_users(self.user1), user1_connections_calls)
64 | user3_connections_msgs = ['0041628436', 'bac412f897']
65 | self.assertEqual(self.msgDataSet.get_connected_users(self.user3), user3_connections_msgs)
66 |
67 | with self.assertRaises(TypeError):
68 | self.callDataSet.get_connected_users(None)
69 | self.callDataSet.get_connected_users(12.3)
70 | self.callDataSet.get_connected_users([self.user1])
71 | self.callDataSet.get_connected_users({self.user1})
72 |
73 | def test_print_connection_matrix(self):
74 | pass
75 |
76 | def test_get_connections(self):
77 | call_connections = [['373a4fb419', '8d27cf2694'], ['329233d117', '6cfc4bd054'], ['e98994c239', '329233d117'],
78 | ['329233d117', '0041628436'], ['329233d117', '0041628436'], ['0041628436', '329233d117'],
79 | ['329233d117', 'bac412f897'], ['11fb537495', '329233d117'], ['bac412f897', '322692e582'],
80 | ['bac412f897', 'c21b973441'], ['bac412f897', '322692e582'], ['bac412f897', '322692e582'],
81 | ['bac412f897', '322692e582'], ['bac412f897', 'c21b973441'], ['bac412f897', '322692e582'],
82 | ['bac412f897', '329233d117'], ['3e97992791', '64e7321526'], ['3e97992791', '2bc2488066'],
83 | ['3e97992791', '2bc2488066'], ['3e97992791', '2f78602598'], ['3e97992791', '2f78602598'],
84 | ['3e97992791', '377415d768'], ['3e97992791', '265034e175'], ['3e97992791', '265034e175'],
85 | ['5973bd0224', '3e97992791'], ['3e97992791', '265034e175'], ['3e97992791', '377415d768'],
86 | ['3e97992791', '377415d768'], ['3e97992791', '265034e175'], ['7331c02864', 'f23eb82163'],
87 | ['7331c02864', 'f23eb82163'], ['7331c02864', 'f23eb82163'], ['7331c02864', '2914c2d+31'],
88 | ['7331c02864', 'f23eb82163'], ['7331c02864', '2914c2d+31'], ['7331c02864', '2914c2d+31'],
89 | ['7331c02864', 'f23eb82163'], ['7331c02864', 'e967db9452'], ['7331c02864', 'ca69f5a563'],
90 | ['7331c02864', '380c65b156'], ['7331c02864', '322692e582'], ['7331c02864', 'e967db9452'],
91 | ['7331c02864', 'e967db9452'], ['7331c02864', 'f23eb82163'], ['7331c02864', 'e967db9452'],
92 | ['7331c02864', '0041628436'], ['7331c02864', '0041628436'], ['7331c02864', '0c47c9c382'],
93 | ['7331c02864', '1ed77db846']]
94 |
95 | self.assertEqual(self.callDataSet.get_connections(allow_duplicates=True), call_connections)
96 |
97 | msg_connections = [['78c4ca6671', '8d27cf2694'], ['0041628436', '329233d117'], ['329233d117', '0041628436'],
98 | ['329233d117', 'bac412f897'], ['bac412f897', '322692e582'], ['322692e582', 'bac412f897'],
99 | ['bac412f897', '322692e582'], ['322692e582', 'bac412f897'], ['bac412f897', '322692e582'],
100 | ['322692e582', 'bac412f897'], ['bac412f897', '322692e582'], ['322692e582', 'bac412f897'],
101 | ['322692e582', 'bac412f897'], ['bac412f897', '322692e582'], ['0041628436', 'bac412f897'],
102 | ['bac412f897', '0041628436'], ['0041628436', 'bac412f897'], ['bac412f897', '0041628436'],
103 | ['329233d117', 'bac412f897'], ['bac412f897', '322692e582'], ['322692e582', 'bac412f897'],
104 | ['bac412f897', '322692e582'], ['322692e582', 'bac412f897'], ['e1ba3ba266', 'bac412f897'],
105 | ['ae578bf678', 'bac412f897'], ['30b785e895', 'bac412f897'], ['bac412f897', '30b785e895'],
106 | ['30b785e895', 'bac412f897'], ['bac412f897', '322692e582'], ['329233d117', 'bac412f897'],
107 | ['bac412f897', '329233d117'], ['322692e582', 'bac412f897'], ['bac412f897', '322692e582'],
108 | ['322692e582', 'bac412f897'], ['bac412f897', '322692e582'], ['322692e582', 'bac412f897'],
109 | ['bac412f897', '322692e582'], ['322692e582', 'bac412f897'], ['bac412f897', '322692e582'],
110 | ['322692e582', 'bac412f897'], ['bac412f897', '322692e582'], ['322692e582', 'bac412f897'],
111 | ['bac412f897', '322692e582'], ['322692e582', 'bac412f897'], ['bac412f897', '322692e582'],
112 | ['322692e582', 'bac412f897'], ['bac412f897', '322692e582'], ['322692e582', 'bac412f897'],
113 | ['bac412f897', '322692e582']]
114 |
115 | self.assertEqual(self.msgDataSet.get_connections(allow_duplicates=True), msg_connections)
116 |
117 |
118 | if __name__ == '__main__':
119 | unittest.main()
120 |
--------------------------------------------------------------------------------
/cellyzer/tools.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import tabulate
3 | import logging
4 | import sys
5 | import webbrowser
6 |
7 | from . import matrix as matrixFile
8 |
9 |
10 | class _AnsiColorizer(object):
11 | _colors = dict(black=30, red=31, green=32, yellow=33,
12 | blue=34, magenta=35, cyan=36, white=37)
13 |
14 | def __init__(self, stream):
15 | self.stream = stream
16 |
17 | @classmethod
18 | def supported(cls, stream=sys.stdout):
19 | if not stream.isatty():
20 | return False # auto color only on TTYs
21 | try:
22 | import curses
23 | except ImportError:
24 | return False
25 | else:
26 | try:
27 | try:
28 | return curses.tigetnum("colors") > 2
29 | except curses.error:
30 | curses.setupterm()
31 | return curses.tigetnum("colors") > 2
32 | except:
33 | raise
34 | # guess false in case of error
35 | return False
36 |
37 | def write(self, text, color):
38 | """
39 | Write the given text to the stream in the given color.
40 | """
41 | color = self._colors[color]
42 | self.stream.write('\x1b[{}m{}\x1b[0m'.format(color, text))
43 |
44 |
45 | class ColorHandler(logging.StreamHandler):
46 | def __init__(self, stream=sys.stderr):
47 | super(ColorHandler, self).__init__(_AnsiColorizer(stream))
48 |
49 | def emit(self, record):
50 | msg_colors = {
51 | logging.DEBUG: ("Debug", "green"),
52 | logging.INFO: ("Info", "blue"),
53 | logging.WARNING: ("Warning", "yellow"),
54 | logging.ERROR: ("Error", "red")
55 | }
56 |
57 | header, color = msg_colors.get(record.levelno, "blue")
58 | if 'prefix' in record.__dict__:
59 | header = record.prefix
60 | else:
61 | header = header + ':'
62 | self.stream.write("{} {}\n".format(header, record.msg), color)
63 |
64 |
65 | def get_weighted_edge_list(edge_list, directed):
66 | weighted_edge_list = []
67 |
68 | if not directed:
69 | # only the connections are cared.
70 | # return a list of lists of [user1,use2,number_of_connections]
71 | for edge in edge_list:
72 | count = edge_list.count(edge)
73 | reversed_edge = edge.copy()
74 | reversed_edge.reverse()
75 | r_count = edge_list.count(reversed_edge)
76 | weight = count + r_count
77 | weighted_edge = edge.copy()
78 | weighted_edge.append(weight)
79 |
80 | not_added = True
81 | for i in weighted_edge_list:
82 | if (edge == [i[0], i[1]]) or (reversed_edge == [i[0], i[1]]):
83 | not_added = False
84 | break
85 | if not_added:
86 | weighted_edge_list.append(weighted_edge)
87 |
88 | return weighted_edge_list
89 | if directed:
90 | # return a list of lists of [user1,use2,number_of_connections]
91 | for edge in edge_list:
92 | weight = edge_list.count(edge)
93 | weighted_edge = edge.copy()
94 | weighted_edge.append(weight)
95 |
96 | not_added = True
97 | for i in weighted_edge_list:
98 | if edge == [i[0], i[1]]:
99 | not_added = False
100 | break
101 | if not_added:
102 | weighted_edge_list.append(weighted_edge)
103 |
104 | return weighted_edge_list
105 |
106 |
107 | def print_matrix(matrix, headers):
108 | print('matrix : ', matrix)
109 | print('header : ', headers)
110 | if len(matrix) > 10:
111 | print("Matrix Length : ", len(matrix))
112 | html = """
113 |
114 |
115 | Connection Matrix
116 |
117 | {table}
118 |
119 |
120 | """
121 | table = tabulate.tabulate(matrix, headers=headers, tablefmt='html', stralign='center')
122 | print('table : ', table)
123 | b = table.encode('utf-8')
124 | f = open('connection_matrix.html', 'wb')
125 | f.write(b)
126 | f.close()
127 | webbrowser.open_new_tab('connection_matrix.html')
128 | else:
129 | print(">> connection matrix")
130 | print(tabulate.tabulate(matrix, headers=headers, tablefmt='pretty'))
131 |
132 |
133 | def print_matrix_new(matrix, headers):
134 | if len(matrix) > 0:
135 | print("Matrix Length : ", len(matrix))
136 | html_tag = matrixFile.matrix_html_head
137 | table_header = create_header(headers)
138 | table_body = create_rows(matrix)
139 | html_tag += ' \n \n'.format(table_header, table_body)
140 | f = open('outputs\\connection_matrix.html', 'w')
141 | f.write(html_tag)
142 | f.close()
143 | webbrowser.open_new_tab('outputs\\connection_matrix.html')
144 |
145 |
146 | def create_rows(matrix, text_align='center'):
147 | row_tag_list = ''
148 | for each_row in matrix:
149 | if each_row[0] != '':
150 | each_row_tag = ''
151 | for each_row_item in each_row:
152 | if each_row_item == each_row[0]:
153 | each_row_items = '| {} | '.format(text_align, each_row_item)
154 | else:
155 | each_row_items = ' {} | '.format(text_align, each_row_item)
156 | each_row_tag += each_row_items
157 | each_row_tag_end = each_row_tag + '
\n'
158 | row_tag_list += each_row_tag_end
159 | row_tag_list_end = row_tag_list + ''
160 | return row_tag_list_end
161 |
162 |
163 | def create_header(headers, text_align='center'):
164 | new_tag = ' \n '
165 | for each_header in headers:
166 | tag = '| {} | '.format(text_align, each_header)
167 | new_tag += tag
168 | tag_end = new_tag + '
\n '
169 | return tag_end
170 |
171 |
172 | def get_datetime_from_timestamp(timestamp):
173 | timestamp.strip()
174 | day, month, date, time, zone, year = timestamp.split()
175 | date, month, year = map(int, [date, month_string_to_number(month), year])
176 | hour, minute, sec = map(int, time.strip().split(":"))
177 | dt = datetime.datetime(year, month, date, hour, minute, sec)
178 | return dt
179 |
180 |
181 | def month_string_to_number(string):
182 | m = {
183 | 'jan': 1,
184 | 'feb': 2,
185 | 'mar': 3,
186 | 'apr': 4,
187 | 'may': 5,
188 | 'jun': 6,
189 | 'jul': 7,
190 | 'aug': 8,
191 | 'sep': 9,
192 | 'oct': 10,
193 | 'nov': 11,
194 | 'dec': 12
195 | }
196 | s = string.strip()[:3].lower()
197 |
198 | try:
199 | out = m[s]
200 | return out
201 | except ValueError:
202 | raise ValueError('Not a month')
203 |
204 |
205 | def get_index_of_day(string):
206 | d = {
207 | 'Mon': 1,
208 | 'Tue': 2,
209 | 'Wed': 3,
210 | 'Thu': 4,
211 | 'Fri': 5,
212 | 'Sat': 6,
213 | 'Sun': 7
214 | }
215 | day = string.split()[0]
216 | try:
217 | out = d[day]
218 | return out
219 | except ValueError:
220 | raise ValueError('Not a day')
221 |
--------------------------------------------------------------------------------
/cellyzer/visualization.py:
--------------------------------------------------------------------------------
1 | """
2 | Graphing classes and Mapping classes are modeled here
3 | """
4 | import networkx as nx
5 | import matplotlib
6 | import matplotlib.pyplot as plt
7 | import numpy as np
8 | import folium
9 | from folium.plugins import MarkerCluster
10 | import webbrowser
11 | import os
12 | import base64
13 | from io import BytesIO
14 |
15 | matplotlib.use("agg")
16 |
17 | plt.rcParams['figure.dpi'] = 200
18 |
19 | try:
20 | os.mkdir('outputs')
21 | except OSError as error:
22 | print(error)
23 |
24 |
25 | def network_graph(edge_list, directed, gui, fig_id, font_size=6, users="All"):
26 | """
27 | Visualize the connections of the given list of users in a graph
28 | Nodes are users and Edges are the connections
29 | The arrow head from A to B represent a call from user A to B
30 | The edge value near the arrow head represents the number of calls made from A to B
31 | :param edge_list: list of 2 user couples with 1st user made a call to the 2nd
32 | :param directed: Bool value to switch between directed and undirected graphs
33 | :param fig_id: unique ID to the figure
34 | :param users: list of users
35 | :return: None, visualizes the graph in a web page
36 | """
37 | plt.figure(fig_id)
38 | if directed:
39 | g = nx.DiGraph()
40 | else:
41 | g = nx.Graph()
42 | for edge in edge_list:
43 | g.add_edge(edge[0], edge[1], weight=edge[2])
44 |
45 | pos = nx.circular_layout(g)
46 | labels = nx.get_edge_attributes(g, 'weight')
47 | nx.draw_networkx(g, pos, font_size=font_size, node_size=800, node_color="lightcoral", node_shape="o",
48 | edge_color="dodgerblue", style="solid", width=2, )
49 | nx.draw_networkx_edge_labels(g, pos, edge_labels=labels, with_labels=True, font_size=font_size, label_pos=0.3)
50 |
51 | tmpfile = BytesIO()
52 | plt.title('Connections of : {}'.format(users), fontsize=8)
53 | plt.savefig(tmpfile, format='png')
54 | encoded = base64.b64encode(tmpfile.getvalue()).decode('utf-8')
55 | html = '' + '

'.format(encoded) + '
'
56 | with open('outputs\\connection_network.html', 'w') as f:
57 | f.write(html)
58 | webbrowser.open("outputs\\connection_network.html")
59 |
60 |
61 | def active_time_bar_chart(time_dict, gui=False, user='xxx', dataset_id='1'):
62 | """
63 | Generates a bar chart of the active time of a given user.
64 | X-axis represents the time(hour of the day)
65 | Y-axis number of records
66 | :param time_dict: Dictionary of hour and activities as key,value pairs
67 | :param user: Given User
68 | :return: None, visualizes the chart in a web page
69 | """
70 | fig_id = user + dataset_id
71 | plt.figure(fig_id)
72 | hours = []
73 | activity = []
74 | for key, value in time_dict.items():
75 | hours.append(key)
76 | activity.append(value)
77 |
78 | y_pos = np.arange(len(hours))
79 | plt.bar(y_pos, activity, align='center', alpha=0.9)
80 | plt.xticks(y_pos, hours, fontsize=6)
81 | plt.ylabel("Activity", fontsize=8)
82 | plt.xlabel("Hours", fontsize=8)
83 | plt.title("Most active times during day - user: " + user, fontsize=8)
84 |
85 | tmpfile = BytesIO()
86 | plt.savefig(tmpfile, format='png')
87 | encoded = base64.b64encode(tmpfile.getvalue()).decode('utf-8')
88 | html = '' + '

'.format(encoded) + '
'
89 | with open('outputs\\active_time_bar_chart.html', 'w') as f:
90 | f.write(html)
91 | webbrowser.open("outputs\\active_time_bar_chart.html")
92 |
93 |
94 | def cell_population_visualization(cell_list, map_name="population_map", notebook=False):
95 | """
96 | Visualize a map with population around cells
97 |
98 | :param cell_list: cells and its respective number of calls
99 | :param map_name: name of the map to be displayed
100 | :param notebook: set to True of runs in a notebook
101 | :return: shows a map with population around cells
102 | """
103 | location = [cell_list[0]['latitude'], cell_list[0]['longitude']]
104 | map1 = folium.Map(location=location, zoom_start=12)
105 | marker_cluster = folium.plugins.MarkerCluster().add_to(map1)
106 | location_list = []
107 | for cell in cell_list:
108 | cell_location = [cell['latitude'], cell['longitude']]
109 | for i in range(int(cell['population_around_cell'])):
110 | location_list.append(cell_location)
111 | for point in location_list:
112 | folium.Marker(location=point,
113 | popup='nothing').add_to(marker_cluster)
114 | if notebook:
115 | return map1
116 | else:
117 | # visualize in web browser
118 | file_path = 'outputs\\' + map_name + '.html'
119 | map1.save(file_path)
120 | webbrowser.open(file_path)
121 |
122 |
123 | def view_home_work_locations(home_location=None, work_location=None, map_name="home_work_location", notebook=False):
124 | """
125 | Visualize a map of home and work locations
126 | :param home_location: home locations
127 | :param work_location: work locations
128 | :param map_name: name of the map to be displayed
129 | :param notebook: set True if run in notebook
130 | :return: shows a map with home/work locations around cells
131 | """
132 |
133 | if home_location is None and work_location is None:
134 | print('XXX home location or work location is not provided with data inputs XXX')
135 | else:
136 | map1 = folium.Map(location=home_location,
137 | zoom_start=11)
138 | if home_location is None:
139 | map1 = folium.Map(location=work_location,
140 | zoom_start=11)
141 | if home_location is not None:
142 | folium.Marker(location=home_location,
143 | popup='Home',
144 | icon=folium.Icon(color='green', icon_color='white', icon='home', angle=0, prefix='fa'),
145 | tooltip='Home Location'
146 | ).add_to(map1)
147 | if work_location is not None:
148 | folium.Marker(location=work_location,
149 | popup='Work Location',
150 | icon=folium.Icon(color='darkblue', icon_color='white', icon='building', angle=0, prefix='fa'),
151 | tooltip='Work Location'
152 | ).add_to(map1)
153 | if notebook:
154 | return map1
155 | else:
156 | # visualize in web browser
157 | file_path = 'outputs\\' + map_name + '.html'
158 | map1.save(file_path)
159 | webbrowser.open(file_path)
160 |
161 |
162 | def create_marked_map(location_list, location="location", value="timestamp"):
163 | if not location_list:
164 | return None
165 | initial_location = location_list[0][location]
166 | marked_map = folium.Map(location=initial_location, tiles="OpenStreetMap", zoom_start=13)
167 | marker_cluster = folium.plugins.MarkerCluster().add_to(marked_map)
168 |
169 | for item in location_list:
170 | loc = item[location]
171 | val = item[value].strftime('%d.%m.%Y %H:%M:%S')
172 | folium.Marker(location=loc, popup=val).add_to(marker_cluster)
173 | return marked_map
174 |
175 |
176 | def trip_visualization(locations, map_name="trip_map", notebook=False):
177 | """
178 | Visualize the trips/routes of a given user in a map
179 | :param locations: Locations visited by the user (sorted in timestamp)
180 | :param map_name: name of the map to be displayed
181 | :param notebook: set true if runs in notebook
182 | :return: shows a map of routes of the user
183 | """
184 | if not locations:
185 | print("No trips to visualize")
186 | return None
187 | marked_map = create_marked_map(locations, value="timestamp")
188 | location_list = []
189 | for item in locations:
190 | location_list.append(item["location"])
191 |
192 | folium.PolyLine(location_list, color='red', weight=12, opacity=0.5).add_to(marked_map)
193 | if notebook:
194 | return marked_map
195 | else:
196 | marked_map.save('outputs\\' + map_name + '.html')
197 | webbrowser.open('outputs\\' + map_name + '.html')
198 |
--------------------------------------------------------------------------------
/tests/unit_tests/test_io.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import cellyzer.io as io
3 |
4 |
5 | class TestIO(unittest.TestCase):
6 |
7 | @classmethod
8 | def setUpClass(cls):
9 | # before all the tests
10 | cls.call_csv_test_path = "../../demo/demo_datasets/test_data/calls.csv"
11 | cls.msg_csv_test_path = "../../demo/demo_datasets/test_data/messages.csv"
12 | cls.cell_csv_test_path = "../../demo/demo_datasets/test_data/antennas.csv"
13 |
14 | cls.call_csv_long_path = "../../demo/demo_datasets/long_data/calls_.csv"
15 | cls.msg_csv_long_path = "../../demo/demo_datasets/long_data/messages_.csv"
16 | cls.cell_csv_long_path = "../../demo/demo_datasets/long_data/antennas.csv"
17 |
18 | cls.call_xlsx_path = "../../demo/demo_datasets/test_data/excel data/calls.xlsx"
19 | cls.msg_xlsx_path = "../../demo/demo_datasets/test_data/excel data/messages.xlsx"
20 | cls.cell_xlsx_path = "../../demo/demo_datasets/test_data/excel data/cell.xlsx"
21 |
22 | cls.call_json_path = "../../demo/demo_datasets/test_data/json data/call.json"
23 | cls.msg_json_path = "../../demo/demo_datasets/test_data/json data/message.json"
24 | cls.cell_json_path = "../../demo/demo_datasets/test_data/json data/cell.json"
25 |
26 | # cls.call_csv_test_obj = io.read_call(cls.call_csv_test_path)
27 |
28 | def test_to_json(self):
29 | with self.assertRaises(TypeError):
30 | io.to_json("obj", "calls")
31 | io.to_json(None, "calls")
32 | io.to_json(io.read_call(self.call_csv_test_path), 123)
33 | io.to_json(io.read_call(self.call_csv_test_path), None)
34 |
35 | def test_to_csv(self):
36 | with self.assertRaises(TypeError):
37 | io.to_csv("obj", "calls")
38 | io.to_csv(None, "calls")
39 | io.to_csv(io.read_call(self.call_csv_test_path), 123)
40 | io.to_csv(io.read_call(self.call_csv_test_path), None)
41 |
42 | def test_read_csv(self):
43 | self.assertEqual(type(io.read_csv(self.call_csv_test_path)).__name__, "DataSet")
44 | self.assertEqual(type(io.read_csv(self.call_csv_long_path)).__name__, "DataSet")
45 | self.assertEqual(type(io.read_csv(self.msg_csv_test_path)).__name__, "DataSet")
46 |
47 | with self.assertRaises(TypeError):
48 | io.read_csv(123)
49 | io.read_csv(None)
50 |
51 | def test_read_call(self):
52 | self.assertEqual(type(io.read_call(self.call_csv_test_path)).__name__, "CallDataSet")
53 | self.assertEqual(type(io.read_call(self.call_csv_long_path)).__name__, "CallDataSet")
54 | self.assertEqual(type(io.read_call(self.call_json_path, file_type="json")).__name__, "CallDataSet")
55 | self.assertEqual(type(io.read_call(self.call_xlsx_path, file_type="xls")).__name__, "CallDataSet")
56 |
57 | with self.assertRaises(TypeError):
58 | io.read_call(file_path=123)
59 | io.read_call(None)
60 | io.read_call(self.call_csv_test_path, file_type=123)
61 | io.read_call(self.call_csv_test_path, file_type=None)
62 | io.read_call(self.call_csv_test_path, hash=123)
63 | io.read_call(self.call_csv_test_path, hash=None)
64 | io.read_call(self.call_csv_test_path, splitted_line={})
65 |
66 | def test_read_msg(self):
67 | self.assertEqual(type(io.read_msg(self.msg_csv_test_path)).__name__, "MessageDataSet")
68 | self.assertEqual(type(io.read_msg(self.msg_json_path, file_type="json")).__name__, "MessageDataSet")
69 | self.assertEqual(type(io.read_msg(self.msg_xlsx_path, file_type="xls")).__name__, "MessageDataSet")
70 |
71 | with self.assertRaises(TypeError):
72 | io.read_msg(file_path=123)
73 | io.read_msg(None)
74 | io.read_msg(self.msg_csv_test_path, file_type=123)
75 | io.read_msg(self.msg_csv_test_path, file_type=None)
76 | io.read_msg(self.msg_csv_test_path, hash=123)
77 | io.read_msg(self.msg_csv_test_path, hash=None)
78 | io.read_msg(self.msg_csv_test_path, splitted_line={})
79 |
80 | def test_read_cell(self):
81 | self.assertEqual(type(io.read_cell(self.cell_csv_test_path)).__name__, "CellDataSet")
82 | self.assertEqual(type(io.read_cell(self.cell_csv_test_path, call_csv_path=self.call_csv_test_path)).__name__,
83 | "CellDataSet")
84 | self.assertEqual(type(
85 | io.read_cell(self.cell_csv_test_path, call_dataset_obj=io.read_call(self.call_csv_test_path))).__name__,
86 | "CellDataSet")
87 | self.assertEqual(type(io.read_cell(self.cell_json_path, file_type="json")).__name__, "CellDataSet")
88 | self.assertEqual(type(io.read_cell(self.cell_xlsx_path, file_type="xlsx")).__name__, "CellDataSet")
89 |
90 | with self.assertRaises(TypeError):
91 | io.read_cell(file_path=123)
92 | io.read_cell(None)
93 | io.read_cell(self.cell_csv_test_path, call_csv_path=123)
94 | io.read_cell(self.cell_csv_test_path, call_dataset_obj=io.read_msg(self.msg_csv_test_path))
95 | io.read_cell(self.cell_csv_test_path, call_dataset_obj="call_data_object")
96 | io.read_cell(self.cell_csv_test_path, file_type=123)
97 | io.read_cell(self.cell_csv_test_path, file_type=None)
98 | io.read_cell(self.cell_csv_test_path, splitted_line={})
99 |
100 | def test_read_xls(self):
101 | self.assertEqual(type(io.read_xls(filepath=self.call_xlsx_path)).__name__, "CallDataSet")
102 | self.assertEqual(type(io.read_xls(filepath=self.msg_xlsx_path)).__name__, "MessageDataSet")
103 | self.assertEqual(type(io.read_xls(filepath=self.cell_xlsx_path)).__name__, "CellDataSet")
104 | self.assertEqual(type(
105 | io.read_xls(filepath=self.call_xlsx_path, call_data_set=io.read_call(self.call_csv_test_path))).__name__,
106 | "CallDataSet")
107 |
108 | with self.assertRaises(TypeError):
109 | io.read_xls(filepath=123)
110 | io.read_xls(filepath=None)
111 | io.read_xls(filepath=self.call_xlsx_path, call_data_set="data obj")
112 | io.read_xls(filepath=self.call_xlsx_path, hash="True")
113 | io.read_xls(filepath=self.call_xlsx_path, hash=None)
114 |
115 | def test_read_json(self):
116 | self.assertEqual(type(io.read_json(filepath=self.call_json_path)).__name__, "CallDataSet")
117 | self.assertEqual(type(io.read_json(filepath=self.msg_json_path)).__name__, "MessageDataSet")
118 | self.assertEqual(type(io.read_json(filepath=self.cell_json_path)).__name__, "CellDataSet")
119 | self.assertEqual(type(
120 | io.read_json(filepath=self.call_json_path, call_data_set=io.read_call(self.call_csv_test_path))).__name__,
121 | "CallDataSet")
122 |
123 | with self.assertRaises(TypeError):
124 | io.read_json(filepath=123)
125 | io.read_json(filepath=None)
126 | io.read_json(filepath=self.call_json_path, hash=None)
127 | io.read_json(filepath=self.call_json_path, hash="True")
128 | io.read_json(filepath=self.call_json_path, hash=123)
129 |
130 | def test_hash_number(self):
131 | self.assertEqual(io.hash_number("0714567893"), "e5f2aad893")
132 | self.assertEqual(io.hash_number(1234567890), "bb3fc34890")
133 | self.assertEqual(io.hash_number(12345.67890), "26defe4789")
134 |
135 | with self.assertRaises(TypeError):
136 | io.hash_number(123)
137 | io.hash_number(None)
138 | io.hash_number([])
139 |
140 | def test_create_call_obj(self):
141 | with self.assertRaises(TypeError):
142 | io.create_call_obj(calls=None, fieldnames=[], hash=True)
143 | io.create_call_obj(calls={}, fieldnames=[], hash=True)
144 | io.create_call_obj(calls=[], fieldnames={}, hash=True)
145 | io.create_call_obj(calls=[], fieldnames=None, hash=True)
146 | io.create_call_obj(calls=[], fieldnames=[], hash="True")
147 | io.create_call_obj(calls=[], fieldnames=[], hash=None)
148 |
149 | def test_create_msg_obj(self):
150 | with self.assertRaises(TypeError):
151 | io.create_msg_obj(messages=None, fieldnames=[], hash=True)
152 | io.create_msg_obj(messages={}, fieldnames=[], hash=True)
153 | io.create_msg_obj(messages=[], fieldnames={}, hash=True)
154 | io.create_msg_obj(messages=[], fieldnames=None, hash=True)
155 | io.create_msg_obj(messages=[], fieldnames=[], hash="True")
156 | io.create_msg_obj(messages=[], fieldnames=[], hash=None)
157 |
158 | def test_create_cell_obj(self):
159 | with self.assertRaises(TypeError):
160 | io.create_cell_obj(cells=None, fieldnames=[], call_data_set=io.read_call(self.call_csv_test_path))
161 | io.create_cell_obj(cells="[]", fieldnames=[], call_data_set=io.read_call(self.call_csv_test_path))
162 | io.create_cell_obj(cells=[], fieldnames=[], call_data_set=None)
163 | io.create_cell_obj(cells=[], fieldnames=[], call_data_set="None")
164 |
165 |
166 | if __name__ == '__main__':
167 | unittest.main()
168 |
--------------------------------------------------------------------------------
/demo/demo_datasets/test_data/json data/message.json:
--------------------------------------------------------------------------------
1 | {
2 | "messagerecords":[
3 | {
4 | "user":7610039694,
5 | "other":7684763671,
6 | "direction":"Incoming",
7 | "length":28,
8 | "timestamp":"Wed Sep 15 19:01:54 +0100 2010"
9 | },
10 | {
11 | "user":7641036117,
12 | "other":7681546436,
13 | "direction":"Incoming",
14 | "length":7,
15 | "timestamp":"Mon Feb 11 07:08:49 +0000 1980"
16 | },
17 | {
18 | "user":7641036117,
19 | "other":7681546436,
20 | "direction":"Outgoing",
21 | "length":6,
22 | "timestamp":"Mon Feb 11 07:14:05 +0000 1980"
23 | },
24 | {
25 | "user":7641036117,
26 | "other":7981267897,
27 | "direction":"Outgoing",
28 | "length":41,
29 | "timestamp":"Thu Sep 09 21:43:44 +0100 2010"
30 | },
31 | {
32 | "user":7981267897,
33 | "other":7784425582,
34 | "direction":"Outgoing",
35 | "length":75,
36 | "timestamp":"Mon Jan 07 22:58:28 +0000 1980"
37 | },
38 | {
39 | "user":7981267897,
40 | "other":7784425582,
41 | "direction":"Incoming",
42 | "length":33,
43 | "timestamp":"Thu Sep 09 18:53:25 +0100 2010"
44 | },
45 | {
46 | "user":7981267897,
47 | "other":7784425582,
48 | "direction":"Outgoing",
49 | "length":90,
50 | "timestamp":"Thu Sep 09 18:59:35 +0100 2010"
51 | },
52 | {
53 | "user":7981267897,
54 | "other":7784425582,
55 | "direction":"Incoming",
56 | "length":30,
57 | "timestamp":"Thu Sep 09 19:06:06 +0100 2010"
58 | },
59 | {
60 | "user":7981267897,
61 | "other":7784425582,
62 | "direction":"Outgoing",
63 | "length":112,
64 | "timestamp":"Thu Sep 09 19:22:28 +0100 2010"
65 | },
66 | {
67 | "user":7981267897,
68 | "other":7784425582,
69 | "direction":"Incoming",
70 | "length":89,
71 | "timestamp":"Thu Sep 09 19:24:50 +0100 2010"
72 | },
73 | {
74 | "user":7981267897,
75 | "other":7784425582,
76 | "direction":"Outgoing",
77 | "length":28,
78 | "timestamp":"Thu Sep 09 19:26:17 +0100 2010"
79 | },
80 | {
81 | "user":7981267897,
82 | "other":7784425582,
83 | "direction":"Incoming",
84 | "length":19,
85 | "timestamp":"Thu Sep 09 19:34:16 +0100 2010"
86 | },
87 | {
88 | "user":7981267897,
89 | "other":7784425582,
90 | "direction":"Incoming",
91 | "length":2,
92 | "timestamp":"Thu Sep 09 19:35:07 +0100 2010"
93 | },
94 | {
95 | "user":7981267897,
96 | "other":7784425582,
97 | "direction":"Outgoing",
98 | "length":43,
99 | "timestamp":"Thu Sep 09 19:35:45 +0100 2010"
100 | },
101 | {
102 | "user":7981267897,
103 | "other":7681546436,
104 | "direction":"Incoming",
105 | "length":19,
106 | "timestamp":"Thu Sep 09 21:31:23 +0100 2010"
107 | },
108 | {
109 | "user":7981267897,
110 | "other":7681546436,
111 | "direction":"Outgoing",
112 | "length":20,
113 | "timestamp":"Thu Sep 09 21:32:11 +0100 2010"
114 | },
115 | {
116 | "user":7981267897,
117 | "other":7681546436,
118 | "direction":"Incoming",
119 | "length":34,
120 | "timestamp":"Thu Sep 09 21:33:45 +0100 2010"
121 | },
122 | {
123 | "user":7981267897,
124 | "other":7681546436,
125 | "direction":"Outgoing",
126 | "length":2,
127 | "timestamp":"Thu Sep 09 21:34:14 +0100 2010"
128 | },
129 | {
130 | "user":7981267897,
131 | "other":7641036117,
132 | "direction":"Incoming",
133 | "length":41,
134 | "timestamp":"Thu Sep 09 21:42:55 +0100 2010"
135 | },
136 | {
137 | "user":7981267897,
138 | "other":7784425582,
139 | "direction":"Outgoing",
140 | "length":23,
141 | "timestamp":"Fri Sep 10 06:36:57 +0100 2010"
142 | },
143 | {
144 | "user":7981267897,
145 | "other":7784425582,
146 | "direction":"Incoming",
147 | "length":13,
148 | "timestamp":"Fri Sep 10 06:38:38 +0100 2010"
149 | },
150 | {
151 | "user":7981267897,
152 | "other":7784425582,
153 | "direction":"Outgoing",
154 | "length":11,
155 | "timestamp":"Fri Sep 10 06:39:10 +0100 2010"
156 | },
157 | {
158 | "user":7981267897,
159 | "other":7784425582,
160 | "direction":"Incoming",
161 | "length":15,
162 | "timestamp":"Fri Sep 10 06:40:56 +0100 2010"
163 | },
164 | {
165 | "user":7981267897,
166 | "other":7033434266,
167 | "direction":"Incoming",
168 | "length":150,
169 | "timestamp":"Fri Sep 10 12:23:21 +0100 2010"
170 | },
171 | {
172 | "user":7981267897,
173 | "other":7817341678,
174 | "direction":"Incoming",
175 | "length":45,
176 | "timestamp":"Fri Sep 10 16:07:38 +0100 2010"
177 | },
178 | {
179 | "user":7981267897,
180 | "other":7541477895,
181 | "direction":"Incoming",
182 | "length":70,
183 | "timestamp":"Fri Sep 10 16:33:49 +0100 2010"
184 | },
185 | {
186 | "user":7981267897,
187 | "other":7541477895,
188 | "direction":"Outgoing",
189 | "length":58,
190 | "timestamp":"Fri Sep 10 16:36:07 +0100 2010"
191 | },
192 | {
193 | "user":7981267897,
194 | "other":7541477895,
195 | "direction":"Incoming",
196 | "length":9,
197 | "timestamp":"Fri Sep 10 16:36:41 +0100 2010"
198 | },
199 | {
200 | "user":7981267897,
201 | "other":7784425582,
202 | "direction":"Outgoing",
203 | "length":14,
204 | "timestamp":"Fri Sep 10 16:40:16 +0100 2010"
205 | },
206 | {
207 | "user":7981267897,
208 | "other":7641036117,
209 | "direction":"Incoming",
210 | "length":20,
211 | "timestamp":"Fri Sep 10 16:47:21 +0100 2010"
212 | },
213 | {
214 | "user":7981267897,
215 | "other":7641036117,
216 | "direction":"Outgoing",
217 | "length":4,
218 | "timestamp":"Fri Sep 10 16:47:45 +0100 2010"
219 | },
220 | {
221 | "user":7981267897,
222 | "other":7784425582,
223 | "direction":"Incoming",
224 | "length":100,
225 | "timestamp":"Fri Sep 10 16:47:59 +0100 2010"
226 | },
227 | {
228 | "user":7981267897,
229 | "other":7784425582,
230 | "direction":"Outgoing",
231 | "length":49,
232 | "timestamp":"Fri Sep 10 16:49:06 +0100 2010"
233 | },
234 | {
235 | "user":7981267897,
236 | "other":7784425582,
237 | "direction":"Incoming",
238 | "length":159,
239 | "timestamp":"Fri Sep 10 16:52:51 +0100 2010"
240 | },
241 | {
242 | "user":7981267897,
243 | "other":7784425582,
244 | "direction":"Outgoing",
245 | "length":86,
246 | "timestamp":"Fri Sep 10 16:55:14 +0100 2010"
247 | },
248 | {
249 | "user":7981267897,
250 | "other":7784425582,
251 | "direction":"Incoming",
252 | "length":57,
253 | "timestamp":"Fri Sep 10 16:56:42 +0100 2010"
254 | },
255 | {
256 | "user":7981267897,
257 | "other":7784425582,
258 | "direction":"Outgoing",
259 | "length":59,
260 | "timestamp":"Fri Sep 10 16:59:18 +0100 2010"
261 | },
262 | {
263 | "user":7981267897,
264 | "other":7784425582,
265 | "direction":"Incoming",
266 | "length":52,
267 | "timestamp":"Fri Sep 10 17:00:37 +0100 2010"
268 | },
269 | {
270 | "user":7981267897,
271 | "other":7784425582,
272 | "direction":"Outgoing",
273 | "length":99,
274 | "timestamp":"Fri Sep 10 17:02:45 +0100 2010"
275 | },
276 | {
277 | "user":7981267897,
278 | "other":7784425582,
279 | "direction":"Incoming",
280 | "length":82,
281 | "timestamp":"Fri Sep 10 17:08:34 +0100 2010"
282 | },
283 | {
284 | "user":7981267897,
285 | "other":7784425582,
286 | "direction":"Outgoing",
287 | "length":71,
288 | "timestamp":"Fri Sep 10 17:10:43 +0100 2010"
289 | },
290 | {
291 | "user":7981267897,
292 | "other":7784425582,
293 | "direction":"Incoming",
294 | "length":31,
295 | "timestamp":"Fri Sep 10 17:29:15 +0100 2010"
296 | },
297 | {
298 | "user":7981267897,
299 | "other":7784425582,
300 | "direction":"Outgoing",
301 | "length":126,
302 | "timestamp":"Fri Sep 10 17:31:56 +0100 2010"
303 | },
304 | {
305 | "user":7981267897,
306 | "other":7784425582,
307 | "direction":"Incoming",
308 | "length":36,
309 | "timestamp":"Fri Sep 10 17:38:26 +0100 2010"
310 | },
311 | {
312 | "user":7981267897,
313 | "other":7784425582,
314 | "direction":"Outgoing",
315 | "length":159,
316 | "timestamp":"Fri Sep 10 17:41:33 +0100 2010"
317 | },
318 | {
319 | "user":7981267897,
320 | "other":7784425582,
321 | "direction":"Incoming",
322 | "length":40,
323 | "timestamp":"Fri Sep 10 17:43:14 +0100 2010"
324 | },
325 | {
326 | "user":7981267897,
327 | "other":7784425582,
328 | "direction":"Outgoing",
329 | "length":74,
330 | "timestamp":"Fri Sep 10 17:47:08 +0100 2010"
331 | },
332 | {
333 | "user":7981267897,
334 | "other":7784425582,
335 | "direction":"Incoming",
336 | "length":29,
337 | "timestamp":"Fri Sep 10 17:48:28 +0100 2010"
338 | },
339 | {
340 | "user":7981267897,
341 | "other":7784425582,
342 | "direction":"Outgoing",
343 | "length":149,
344 | "timestamp":"Fri Sep 10 17:54:40 +0100 2010"
345 | }
346 | ]
347 | }
--------------------------------------------------------------------------------
/tests/unit_tests/test_CellDataSet.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import cellyzer.core as core
3 | import cellyzer.io as io
4 | import datetime
5 |
6 |
7 | class TestCellDataSet(unittest.TestCase):
8 |
9 | @classmethod
10 | def setUpClass(cls):
11 | # before all the tests
12 | cls.callDataSet = core.CallDataSet()
13 | call_file_path = "../../demo/demo_datasets/test_data/calls.csv"
14 | cls.callDataSet = io.read_call(call_file_path)
15 |
16 | cell_file_path = "../../demo/demo_datasets/test_data/antennas.csv"
17 | cls.cellDataSet = io.read_cell(cell_file_path, call_dataset_obj=cls.callDataSet)
18 |
19 | @classmethod
20 | def tearDownClass(cls):
21 | # after all the tests
22 | pass
23 |
24 | def setUp(self):
25 | # run before each test
26 | pass
27 |
28 | def tearDown(self):
29 | # run after each test
30 | pass
31 |
32 | # functions
33 | def test_get_cell_records(self):
34 | self.assertEqual(len(self.cellDataSet.get_cell_records()), 27)
35 | self.assertEqual(self.cellDataSet.get_cell_records(1).get_cell_id(), '1')
36 | self.assertEqual(self.cellDataSet.get_cell_records("1").get_cell_id(), '1')
37 | self.assertEqual(self.cellDataSet.get_cell_records(1.1), None)
38 |
39 | with self.assertRaises(TypeError):
40 | self.cellDataSet.get_cell_records([])
41 | self.cellDataSet.get_cell_records({})
42 |
43 | def test_get_location(self):
44 | self.assertEqual(self.cellDataSet.get_location(1), (42.366944, -71.083611))
45 | self.assertEqual(self.cellDataSet.get_location('1'), (42.366944, -71.083611))
46 | self.assertEqual(self.cellDataSet.get_location('1.1'), None)
47 |
48 | with self.assertRaises(TypeError):
49 | self.cellDataSet.get_location([])
50 | self.cellDataSet.get_location({})
51 | self.cellDataSet.get_location(None)
52 |
53 | def test_get_population(self):
54 | all_cell_population = [
55 | {'cell_id': '1', 'latitude': '42.366944', 'longitude': '-71.083611', 'population_around_cell': 1},
56 | {'cell_id': '2', 'latitude': '42.386722', 'longitude': '-71.138778', 'population_around_cell': 2},
57 | {'cell_id': '3', 'latitude': '42.3604', 'longitude': '-71.087374', 'population_around_cell': 0},
58 | {'cell_id': '4', 'latitude': '42.353917', 'longitude': '-71.105', 'population_around_cell': 0},
59 | {'cell_id': '5', 'latitude': '42.36', 'longitude': '-71.12', 'population_around_cell': 0},
60 | {'cell_id': '6', 'latitude': '42.375', 'longitude': '-71.1', 'population_around_cell': 0},
61 | {'cell_id': '7', 'latitude': '42.345', 'longitude': '-71.09', 'population_around_cell': 0},
62 | {'cell_id': '8', 'latitude': '42.39', 'longitude': '-71.105', 'population_around_cell': 0},
63 | {'cell_id': '9', 'latitude': '42.38', 'longitude': '-71.09', 'population_around_cell': 0},
64 | {'cell_id': '10', 'latitude': '42.304917', 'longitude': '-71.147374', 'population_around_cell': 2},
65 | {'cell_id': '11', 'latitude': '42.373917', 'longitude': '-70.067374', 'population_around_cell': 0},
66 | {'cell_id': '12', 'latitude': '42.313917', 'longitude': '-71.037374', 'population_around_cell': 0},
67 | {'cell_id': '13', 'latitude': '42.40944', 'longitude': '-71.1', 'population_around_cell': 0},
68 | {'cell_id': '14', 'latitude': '42.41', 'longitude': '-71.073', 'population_around_cell': 0},
69 | {'cell_id': '15', 'latitude': '42.44', 'longitude': '-71.15', 'population_around_cell': 0},
70 | {'cell_id': '16', 'latitude': '42.48', 'longitude': '-71.23', 'population_around_cell': 0},
71 | {'cell_id': '17', 'latitude': '42.35', 'longitude': '-71.05', 'population_around_cell': 0},
72 | {'cell_id': '18', 'latitude': '42.33', 'longitude': '-71.11', 'population_around_cell': 0},
73 | {'cell_id': '19', 'latitude': '42.36', 'longitude': '-71.25', 'population_around_cell': 0},
74 | {'cell_id': '20', 'latitude': '42.413', 'longitude': '-71.143', 'population_around_cell': 0},
75 | {'cell_id': '21', 'latitude': '42.373917', 'longitude': '-71.215', 'population_around_cell': 0},
76 | {'cell_id': '22', 'latitude': '43.37', 'longitude': '-71.085', 'population_around_cell': 0},
77 | {'cell_id': '23', 'latitude': '43.39', 'longitude': '-71.11', 'population_around_cell': 0},
78 | {'cell_id': '24', 'latitude': '42.29', 'longitude': '-71.13', 'population_around_cell': 0},
79 | {'cell_id': '25', 'latitude': '42.31', 'longitude': '-71.16', 'population_around_cell': 0},
80 | {'cell_id': '26', 'latitude': '42.313', 'longitude': '-71.135', 'population_around_cell': 0},
81 | {'cell_id': '27', 'latitude': '42.297', 'longitude': '-71.155', 'population_around_cell': 0}]
82 | self.assertEqual(self.cellDataSet.get_population(), all_cell_population)
83 |
84 | self.assertEqual(self.cellDataSet.get_population("1"),
85 | {'cell_id': '1', 'latitude': '42.366944', 'longitude': '-71.083611',
86 | 'population_around_cell': 1})
87 | self.assertEqual(self.cellDataSet.get_population("1.1"), None)
88 | with self.assertRaises(TypeError):
89 | self.cellDataSet.get_population([])
90 | self.cellDataSet.get_population({})
91 |
92 | def test_get_unique_users_around_cell(self):
93 | test = self.callDataSet.get_records()
94 | result = ['8d27cf2694', '329233d117', 'bac412f897', '3e97992791', '7331c02864']
95 | self.assertEqual(self.cellDataSet.get_unique_users_around_cell(test), result)
96 |
97 | def test_check_user_location_matches_cell(self):
98 | self.assertEqual(self.cellDataSet.check_user_location_matches_cell('3e97992791', 10), True)
99 | self.assertEqual(self.cellDataSet.check_user_location_matches_cell('3e97992791', 2), False)
100 | self.assertEqual(self.cellDataSet.check_user_location_matches_cell('3e97992791', 2.2), False)
101 | self.assertEqual(self.cellDataSet.check_user_location_matches_cell('123', 10), False)
102 |
103 | with self.assertRaises(TypeError):
104 | self.cellDataSet.check_user_location_matches_cell([], [])
105 | self.cellDataSet.check_user_location_matches_cell(None, 2)
106 | self.cellDataSet.check_user_location_matches_cell(2, None)
107 | self.cellDataSet.check_user_location_matches_cell({}, 2)
108 | self.cellDataSet.check_user_location_matches_cell(None, [])
109 |
110 | def test_get_trip_details(self):
111 | result = [{'timestamp': datetime.datetime(2010, 9, 9, 18, 16, 47), 'duration': '0', 'cell_id': '1',
112 | 'location': (42.366944, -71.083611)},
113 | {'timestamp': datetime.datetime(2010, 9, 9, 18, 37, 5), 'duration': '0', 'cell_id': '2',
114 | 'location': (42.386722, -71.138778)},
115 | {'timestamp': datetime.datetime(2010, 9, 9, 19, 3, 5), 'duration': '0', 'cell_id': '2',
116 | 'location': (42.386722, -71.138778)},
117 | {'timestamp': datetime.datetime(2010, 9, 9, 20, 2, 16), 'duration': '0', 'cell_id': '2',
118 | 'location': (42.386722, -71.138778)},
119 | {'timestamp': datetime.datetime(2010, 9, 9, 20, 57, 51), 'duration': '0', 'cell_id': '3',
120 | 'location': (42.3604, -71.087374)},
121 | {'timestamp': datetime.datetime(2010, 9, 9, 22, 7, 39), 'duration': '0', 'cell_id': '3',
122 | 'location': (42.3604, -71.087374)},
123 | {'timestamp': datetime.datetime(2010, 9, 9, 22, 8, 8), 'duration': '0', 'cell_id': '3',
124 | 'location': (42.3604, -71.087374)},
125 | {'timestamp': datetime.datetime(2010, 9, 9, 22, 12, 1), 'duration': '215', 'cell_id': '2',
126 | 'location': (42.386722, -71.138778)},
127 | {'timestamp': datetime.datetime(2010, 9, 9, 22, 38, 9), 'duration': '41', 'cell_id': '2',
128 | 'location': (42.386722, -71.138778)},
129 | {'timestamp': datetime.datetime(2010, 9, 9, 23, 2, 56), 'duration': '0', 'cell_id': '2',
130 | 'location': (42.386722, -71.138778)},
131 | {'timestamp': datetime.datetime(2010, 9, 9, 23, 18, 13), 'duration': '0', 'cell_id': '2',
132 | 'location': (42.386722, -71.138778)},
133 | {'timestamp': datetime.datetime(2010, 9, 9, 23, 21, 5), 'duration': '0', 'cell_id': '2',
134 | 'location': (42.386722, -71.138778)},
135 | {'timestamp': datetime.datetime(2010, 9, 9, 23, 28, 24), 'duration': '4', 'cell_id': '2',
136 | 'location': (42.386722, -71.138778)},
137 | {'timestamp': datetime.datetime(2010, 9, 10, 6, 1, 27), 'duration': '52', 'cell_id': '1',
138 | 'location': (42.366944, -71.083611)},
139 | {'timestamp': datetime.datetime(2010, 9, 10, 6, 4, 43), 'duration': '0', 'cell_id': '2',
140 | 'location': (42.386722, -71.138778)},
141 | {'timestamp': datetime.datetime(2010, 9, 10, 7, 45, 52), 'duration': '39', 'cell_id': '4',
142 | 'location': (42.353917, -71.105)},
143 | {'timestamp': datetime.datetime(2010, 9, 10, 7, 53, 9), 'duration': '0', 'cell_id': '2',
144 | 'location': (42.386722, -71.138778)},
145 | {'timestamp': datetime.datetime(2010, 9, 10, 7, 54, 2), 'duration': '0', 'cell_id': '1',
146 | 'location': (42.366944, -71.083611)},
147 | {'timestamp': datetime.datetime(2010, 9, 10, 11, 15, 49), 'duration': '0', 'cell_id': '10',
148 | 'location': (42.304917, -71.147374)},
149 | {'timestamp': datetime.datetime(2010, 9, 10, 19, 35, 57), 'duration': '0', 'cell_id': '1',
150 | 'location': (42.366944, -71.083611)}]
151 |
152 | self.assertEqual(self.cellDataSet.get_trip_details("7331c02864"), result)
153 |
154 | with self.assertRaises(TypeError):
155 | self.cellDataSet.get_trip_details("7331c02864", console_print='str')
156 | self.cellDataSet.get_trip_details("7331c02864", tabulate='str')
157 | self.cellDataSet.get_trip_details("7331c02864", console_print='str', tabulate='str')
158 | self.cellDataSet.get_trip_details(12.3)
159 | self.cellDataSet.get_trip_details([])
160 | self.cellDataSet.get_trip_details({})
161 |
162 |
163 | if __name__ == '__main__':
164 | unittest.main()
165 |
--------------------------------------------------------------------------------
/cellyzer_gui/assets/gui.css:
--------------------------------------------------------------------------------
1 |
2 | .index_page_CELLYZER {
3 | text-align: center;
4 | color: orange;
5 | background: black;
6 | padding-top: 20px;
7 | padding-bottom: 20px;
8 | }
9 |
10 | .index_page_Dashboard {
11 | color: white;
12 | padding-left: 5px;
13 | padding-right: 5px;
14 | }
15 |
16 | .index_page_dataset_div {
17 | padding: 6px 8px 6px 20px;
18 | text-decoration: none;
19 | font-size: 22px;
20 | color: white;
21 | display: block;
22 | }
23 |
24 | .index_page_Dashboard_div {
25 | height: 100%;
26 | width: 240px;
27 | position: fixed;
28 | z-index: 1;
29 | top: 0;
30 | left: 0;
31 | background-color:black;
32 | overflow-x: hidden;
33 | padding-top: 20px;
34 | }
35 |
36 | .index_page_Img {
37 | width: 100%;
38 | height: 500px;
39 | }
40 |
41 | .index_page_welcome {
42 | position: absolute;
43 | bottom: 200px;
44 | background: rgba(0, 0, 0, 0.5);
45 | color: orange;
46 | width: 100%;
47 | text-align: center;
48 | font-weight: 900;
49 | font-size: 20px;
50 | }
51 |
52 | .index_page_welcome_div {
53 | position: relative;
54 | max-width: 1300px;
55 | margin: 0px auto;
56 | color: #007bff;
57 | }
58 |
59 | .index_page_div {
60 | margin-left: 222px;
61 | padding: 0px 10px;
62 | }
63 |
64 | .index_dataset_CELLYZER {
65 | text-align: center;
66 | color: orange;
67 | background: black;
68 | padding-top: 20px;
69 | padding-bottom: 20px;
70 | }
71 |
72 | .index_dataset_Dasboard {
73 | color: white;
74 | padding-left: 20px;
75 | }
76 |
77 | .index_dataset_Call_Dataset {
78 | padding: 6px 8px 6px 20px;
79 | text-decoration: none;
80 | font-size: 22px;
81 | color: white;
82 | display: block;
83 | margin-left: 20px;
84 | }
85 |
86 | .index_dataset_Dashboard_div {
87 | height: 100%;
88 | width: 240px;
89 | position: fixed;
90 | z-index: 1;
91 | top: 0;
92 | left: 0;
93 | background-color:#111;
94 | overflow-x: hidden;
95 | padding-top: 20px;
96 | margin-top: 8px;
97 | }
98 |
99 | .index_dataset_add_call_data {
100 | background: gray;
101 | padding-top: 10px;
102 | padding-bottom: 10px;
103 | padding-left: 50px;
104 | color: white;
105 | text-align: left;
106 | }
107 |
108 | .index_dataset_add_call_data_div {
109 | width: 100%;
110 | margin-top: 50px;
111 | padding-left: 30px;
112 | }
113 |
114 | .index_datatset_calldata_button {
115 | background-color: #4CAF50;
116 | height: 50px;
117 | border: none;
118 | color: white;
119 | text-align: center;
120 | text-decoration: none;
121 | display: inline-block;
122 | font-size: 16px;
123 | margin: 4px 6px;
124 | margin-bottom: 20px;
125 | cursor: pointer;
126 | }
127 |
128 | .index_dataset_upload_data {
129 | margin-top: 30px;
130 | }
131 |
132 | .index_dataset_div {
133 | margin-left: 250px;
134 | padding: 10px 10px;
135 | background-color: white;
136 | height: 600px;
137 | }
138 |
139 | .call_dataset_input_div{
140 | height: 500px;
141 | }
142 |
143 | .call_page_welcome_div {
144 | position: relative;
145 | max-width: 1300px;
146 | margin: 20px 20px;
147 | color: #007bff;
148 | font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
149 | font-weight: 300!important;
150 | }
151 |
152 | .call_dataset_div {
153 | margin-left: 250px;
154 | padding: 10px 10px;
155 | background-color: white;
156 | height: 600px;
157 | }
158 |
159 |
160 | .sample_call_data_cellyzer {
161 | text-align: center;
162 | color: orange;
163 | background: black;
164 | padding-top: 20px;
165 | padding-bottom: 20px;
166 | }
167 |
168 | .sample_call_dataset_Dashboard {
169 | color: white;
170 | padding-left: 20px;
171 | }
172 |
173 | .sample_call_dataset_h5 {
174 | padding: 6px 8px 6px 20px;
175 | text-decoration: none;
176 | font-size: 22px;
177 | color: white;
178 | display: block;
179 | }
180 |
181 | .sample_dataset_Dashboard_div {
182 | height: 100%;
183 | width: 240px;
184 | position: fixed;
185 | z-index: 1;
186 | top: 0;
187 | left: 0;
188 | background-color:#111;
189 | overflow-x: hidden;
190 | padding-top: 20px;
191 | margin-top: 8px;
192 | }
193 |
194 | .sample_dataset_visualize {
195 | width: 1065px;
196 | margin-top: 50px;
197 | padding-left: 0px;
198 | margin-bottom: 40px;
199 | }
200 |
201 | .sample_call_data_visualize_option {
202 | padding-left: 30px;
203 | font-size: 22px;
204 | display: block;
205 | background: rgba(0, 0, 0, 0.664);
206 | padding-top: 40px;
207 | padding-bottom: 40px;
208 | }
209 |
210 | .sample_call_dataset_viewdata {
211 | margin: 4px 6px;
212 | margin-bottom: 20px;
213 | cursor: pointer;
214 |
215 | }
216 |
217 | .sample_call_dataset_close {
218 | margin: 4px 6px;
219 | margin-bottom: 20px;
220 | cursor: pointer;
221 | }
222 |
223 | .sample_call_dataset_view_div {
224 | padding-left: 40px;
225 | }
226 |
227 | .sample_call_dataset_show{
228 | padding-left: 40px;
229 | margin-top: 30px;
230 | }
231 |
232 | .sample_call_dataset_show_all_users{
233 | padding-left: 40px;
234 | margin-top: 30px;
235 | }
236 |
237 | .sample_call_dataset_div {
238 | margin-left: 222px;
239 | padding: 0px 10px;
240 | padding-left: 28px;
241 | }
242 |
243 | .index_cell_dataset_cellyzer {
244 | text-align: center;
245 | color: orange;
246 | background: black;
247 | padding-top: 20px;
248 | padding-bottom: 20px;
249 | }
250 |
251 | .index_cell_dataset_Dashboard{
252 | color: white;
253 | padding-left: 20px;
254 | }
255 |
256 | .index_cell_dataset_h5 {
257 | padding: 6px 8px 6px 20px;
258 | text-decoration: none;
259 | font-size: 22px;
260 | color: white;
261 | display: block;
262 | }
263 |
264 | .index_cell_dataset_Dashboard_div {
265 | height: 100%;
266 | width: 240px;
267 | position: fixed;
268 | z-index: 1;
269 | top: 0;
270 | left: 0;
271 | background-color:#111;
272 | overflow-x: hidden;
273 | padding-top: 20px;
274 | margin-top: 8px;
275 | }
276 |
277 | .index_cell_dataset_addcell {
278 | background: gray;
279 | padding-top: 10px;
280 | padding-bottom: 10px;
281 | padding-left: 50px;
282 | color: white;
283 | }
284 |
285 | .index_cell_dataset_addcell_div {
286 | width: 700px;
287 | margin-top: 50px;
288 | padding-left: 30px;
289 | }
290 |
291 | .index_celldata_add_button {
292 | background-color: #4CAF50;
293 | height: 50px;
294 | border: none;
295 | color: white;
296 | text-align: center;
297 | text-decoration: none;
298 | display: inline-block;
299 | font-size: 16px;
300 | margin: 4px 6px;
301 | margin-bottom: 20px;
302 | cursor: pointer;
303 | }
304 |
305 | .index_cell_dataset_upload_data {
306 | margin-top: 30px;
307 | }
308 |
309 | .index_cell_dataset_div {
310 | margin-left: 222px;
311 | padding: 0px 10px;
312 | }
313 |
314 | .sample_cell_data_cellyzer {
315 | text-align: center;
316 | color: orange;
317 | background: black;
318 | padding-top: 20px;
319 | padding-bottom: 20px;
320 | }
321 |
322 | .sample_cell_dataset_Dashboard {
323 | color: white;
324 | padding-left: 20px;
325 | }
326 |
327 | .sample_cell_dataset_h5 {
328 | padding: 6px 8px 6px 20px;
329 | text-decoration: none;
330 | font-size: 22px;
331 | color: white;
332 | display: block;
333 | }
334 |
335 | .sample_cell_dataset_Dashboard_div {
336 | height: 100%;
337 | width: 240px;
338 | position: fixed;
339 | z-index: 1;
340 | top: 0;
341 | left: 0;
342 | background-color:#111;
343 | overflow-x: hidden;
344 | padding-top: 20px;
345 | margin-top: 8px;
346 | }
347 |
348 | .sample_cell_dataset_viewdata {
349 | background-color: #4CAF50;
350 | height: 50px;
351 | border: none;
352 | color: white;
353 | text-align: center;
354 | text-decoration: none;
355 | font-size: 16px;
356 | margin: 4px 6px;
357 | margin-bottom: 20px;
358 | cursor: pointer;
359 | float: left;
360 | }
361 |
362 | .sample_cell_dataset_close {
363 | background-color: #4CAF50;
364 | height: 50px;
365 | border: none;
366 | color: white;
367 | text-align: center;
368 | text-decoration: none;
369 | font-size: 16px;
370 | margin: 4px 6px;
371 | margin-bottom: 20px;
372 | cursor: pointer;
373 | float: right;
374 | }
375 |
376 | .sample_cell_dataset_view_div {
377 | padding-left: 30px;
378 | }
379 |
380 | .sample_cell_dataset_show{
381 | padding-left: 20px;
382 | margin-top: 30px;
383 | }
384 |
385 | .sample_cell_dataset_div {
386 | margin-left: 222px;
387 | padding: 0px 10px;
388 | }
389 |
390 | .index_message_dataset_cellyzer {
391 | text-align: center;
392 | color: orange;
393 | background: black;
394 | padding-top: 20px;
395 | padding-bottom: 20px;
396 | }
397 |
398 | .index_message_dataset_Dashboard{
399 | color: white;
400 | padding-left: 20px;
401 | }
402 |
403 | .index_message_dataset_h5 {
404 | padding: 6px 8px 6px 20px;
405 | text-decoration: none;
406 | font-size: 22px;
407 | color: white;
408 | display: block;
409 | }
410 |
411 | .index_message_dataset_Dashboard_div {
412 | height: 100%;
413 | width: 240px;
414 | position: fixed;
415 | z-index: 1;
416 | top: 0;
417 | left: 0;
418 | background-color:#111;
419 | overflow-x: hidden;
420 | padding-top: 20px;
421 | margin-top: 8px;
422 | }
423 |
424 | .index_message_dataset_addmessage {
425 | background: gray;
426 | padding-top: 10px;
427 | padding-bottom: 10px;
428 | padding-left: 50px;
429 | color: white;
430 | }
431 |
432 | .index_message_dataset_addmessage_div {
433 | width: 700px;
434 | margin-top: 50px;
435 | padding-left: 30px;
436 | }
437 |
438 | .index_messagedata_add_button {
439 | background-color: #4CAF50;
440 | height: 50px;
441 | border: none;
442 | color: white;
443 | text-align: center;
444 | text-decoration: none;
445 | display: inline-block;
446 | font-size: 16px;
447 | margin: 4px 6px;
448 | margin-bottom: 20px;
449 | cursor: pointer;
450 | }
451 |
452 | .index_message_dataset_upload_data {
453 | margin-top: 30px;
454 | }
455 |
456 | .index_message_dataset_div {
457 | margin-left: 222px;
458 | padding: 0px 10px;
459 | }
460 |
461 | .sample_message_data_cellyzer {
462 | text-align: center;
463 | color: orange;
464 | background: black;
465 | padding-top: 20px;
466 | padding-bottom: 20px;
467 | }
468 |
469 | .sample_message_dataset_Dashboard {
470 | color: white;
471 | padding-left: 20px;
472 | }
473 |
474 | .sample_message_dataset_h5 {
475 | padding: 6px 8px 6px 20px;
476 | text-decoration: none;
477 | font-size: 22px;
478 | color: white;
479 | display: block;
480 | }
481 |
482 | .sample_message_dataset_Dashboard_div {
483 | height: 100%;
484 | width: 240px;
485 | position: fixed;
486 | z-index: 1;
487 | top: 0;
488 | left: 0;
489 | background-color:#111;
490 | overflow-x: hidden;
491 | padding-top: 20px;
492 | margin-top: 8px;
493 | }
494 |
495 | .sample_message_dataset_viewdata {
496 | background-color: #4CAF50;
497 | height: 50px;
498 | border: none;
499 | color: white;
500 | text-align: center;
501 | text-decoration: none;
502 | font-size: 16px;
503 | margin: 4px 6px;
504 | margin-bottom: 20px;
505 | cursor: pointer;
506 | float: left;
507 | }
508 |
509 | .sample_message_dataset_close {
510 | background-color: #4CAF50;
511 | height: 50px;
512 | border: none;
513 | color: white;
514 | text-align: center;
515 | text-decoration: none;
516 | font-size: 16px;
517 | margin: 4px 6px;
518 | margin-bottom: 20px;
519 | cursor: pointer;
520 | float: right;
521 | }
522 |
523 | .sample_message_dataset_view_div {
524 | padding-left: 30px;
525 | }
526 |
527 | .sample_message_dataset_show{
528 | padding-left: 20px;
529 | margin-top: 30px;
530 | }
531 |
532 | .sample_message_dataset_div {
533 | margin-left: 222px;
534 | padding: 0px 10px;
535 | }
536 |
537 | .sample_call_visualize_all_user {
538 | color: orange;
539 | background: black;
540 | padding-top: 10px;
541 | padding-bottom: 10px;
542 | width: 700px;
543 | padding-left: 90px;
544 | }
545 |
546 | .index_page_dataset_div_all_user {
547 | padding-left: 40px;
548 | text-decoration: none;
549 | font-size: 22px;
550 | color: white;
551 | display: block;
552 | }
553 |
554 | .index_dataset_cell_record_div {
555 | width: 200px;
556 | margin-top: 50px;
557 | padding-left: 30px;
558 | }
--------------------------------------------------------------------------------
/demo/demo_datasets/test_data/json data/call.json:
--------------------------------------------------------------------------------
1 | {
2 | "callrecords":[
3 | {
4 | "user":7610039694,
5 | "other":7434677419,
6 | "direction":"Incoming",
7 | "duration":211,
8 | "timestamp":"Wed Sep 15 19:17:44 +0100 2010",
9 | "antenna_id":2,
10 | "cost":8
11 | },
12 | {
13 | "user":7641036117,
14 | "other":1666472054,
15 | "direction":"Outgoing",
16 | "duration":31,
17 | "timestamp":"Mon Feb 11 07:18:23 +0000 1980",
18 | "antenna_id":10,
19 | "cost":2
20 | },
21 | {
22 | "user":7641036117,
23 | "other":7371326239,
24 | "direction":"Incoming",
25 | "duration":45,
26 | "timestamp":"Mon Feb 11 07:45:42 +0000 1980",
27 | "antenna_id":2,
28 | "cost":2
29 | },
30 | {
31 | "user":7641036117,
32 | "other":7681546436,
33 | "direction":"Outgoing",
34 | "duration":10,
35 | "timestamp":"Mon Feb 11 08:04:42 +0000 1980",
36 | "antenna_id":3,
37 | "cost":2
38 | },
39 | {
40 | "user":7641036117,
41 | "other":7681546436,
42 | "direction":"Outgoing",
43 | "duration":0,
44 | "timestamp":"Mon Feb 11 08:05:31 +0000 1980",
45 | "antenna_id":4,
46 | "cost":0
47 | },
48 | {
49 | "user":7641036117,
50 | "other":7681546436,
51 | "direction":"Incoming",
52 | "duration":0,
53 | "timestamp":"Mon Feb 11 08:06:18 +0000 1980",
54 | "antenna_id":5,
55 | "cost":0
56 | },
57 | {
58 | "user":7641036117,
59 | "other":7981267897,
60 | "direction":"Outgoing",
61 | "duration":0,
62 | "timestamp":"Mon Feb 11 08:06:31 +0000 1980",
63 | "antenna_id":6,
64 | "cost":0
65 | },
66 | {
67 | "user":7641036117,
68 | "other":7588304495,
69 | "direction":"Incoming",
70 | "duration":124,
71 | "timestamp":"Thu Sep 09 19:35:37 +0100 2010",
72 | "antenna_id":7,
73 | "cost":6
74 | },
75 | {
76 | "user":7981267897,
77 | "other":7784425582,
78 | "direction":"Outgoing",
79 | "duration":474,
80 | "timestamp":"Thu Sep 09 18:43:44 +0100 2010",
81 | "antenna_id":5,
82 | "cost":16
83 | },
84 | {
85 | "user":7981267897,
86 | "other":7743039441,
87 | "direction":"Missed",
88 | "duration":0,
89 | "timestamp":"Thu Sep 09 19:51:30 +0100 2010",
90 | "antenna_id":3,
91 | "cost":0
92 | },
93 | {
94 | "user":7981267897,
95 | "other":7784425582,
96 | "direction":"Outgoing",
97 | "duration":0,
98 | "timestamp":"Thu Sep 09 20:57:55 +0100 2010",
99 | "antenna_id":1,
100 | "cost":0
101 | },
102 | {
103 | "user":7981267897,
104 | "other":7784425582,
105 | "direction":"Outgoing",
106 | "duration":605,
107 | "timestamp":"Fri Sep 10 20:17:00 +0100 2010",
108 | "antenna_id":1,
109 | "cost":22
110 | },
111 | {
112 | "user":7981267897,
113 | "other":7784425582,
114 | "direction":"Outgoing",
115 | "duration":1,
116 | "timestamp":"Sat Sep 11 16:44:56 +0100 2010",
117 | "antenna_id":1,
118 | "cost":2
119 | },
120 | {
121 | "user":7981267897,
122 | "other":7743039441,
123 | "direction":"Outgoing",
124 | "duration":59,
125 | "timestamp":"Sat Sep 11 17:00:59 +0100 2010",
126 | "antenna_id":2,
127 | "cost":2
128 | },
129 | {
130 | "user":7981267897,
131 | "other":7784425582,
132 | "direction":"Outgoing",
133 | "duration":1201,
134 | "timestamp":"Mon Sep 13 14:53:26 +0100 2010",
135 | "antenna_id":3,
136 | "cost":42
137 | },
138 | {
139 | "user":7981267897,
140 | "other":7641036117,
141 | "direction":"Outgoing",
142 | "duration":2,
143 | "timestamp":"Tue Sep 14 07:19:17 +0100 2010",
144 | "antenna_id":1,
145 | "cost":2
146 | },
147 | {
148 | "user":7163185791,
149 | "other":1850897526,
150 | "direction":"Outgoing",
151 | "duration":0,
152 | "timestamp":"Thu Sep 09 21:05:12 +0100 2010",
153 | "antenna_id":10,
154 | "cost":0
155 | },
156 | {
157 | "user":7163185791,
158 | "other":7066875066,
159 | "direction":"Outgoing",
160 | "duration":0,
161 | "timestamp":"Fri Sep 10 18:14:22 +0100 2010",
162 | "antenna_id":2,
163 | "cost":0
164 | },
165 | {
166 | "user":7163185791,
167 | "other":7066875066,
168 | "direction":"Outgoing",
169 | "duration":0,
170 | "timestamp":"Fri Sep 10 18:14:46 +0100 2010",
171 | "antenna_id":2,
172 | "cost":0
173 | },
174 | {
175 | "user":7163185791,
176 | "other":7691640598,
177 | "direction":"Outgoing",
178 | "duration":0,
179 | "timestamp":"Fri Sep 10 18:16:16 +0100 2010",
180 | "antenna_id":2,
181 | "cost":0
182 | },
183 | {
184 | "user":7163185791,
185 | "other":7691640598,
186 | "direction":"Outgoing",
187 | "duration":0,
188 | "timestamp":"Fri Sep 10 18:17:32 +0100 2010",
189 | "antenna_id":2,
190 | "cost":0
191 | },
192 | {
193 | "user":7163185791,
194 | "other":8704500768,
195 | "direction":"Missed",
196 | "duration":0,
197 | "timestamp":"Tue Sep 14 13:18:18 +0100 2010",
198 | "antenna_id":2,
199 | "cost":0
200 | },
201 | {
202 | "user":7163185791,
203 | "other":7187432175,
204 | "direction":"Outgoing",
205 | "duration":39,
206 | "timestamp":"Tue Sep 14 15:23:43 +0100 2010",
207 | "antenna_id":2,
208 | "cost":2
209 | },
210 | {
211 | "user":7163185791,
212 | "other":7187432175,
213 | "direction":"Outgoing",
214 | "duration":3,
215 | "timestamp":"Tue Sep 14 15:27:12 +0100 2010",
216 | "antenna_id":2,
217 | "cost":2
218 | },
219 | {
220 | "user":7163185791,
221 | "other":7230262224,
222 | "direction":"Incoming",
223 | "duration":47,
224 | "timestamp":"Tue Sep 14 15:28:16 +0100 2010",
225 | "antenna_id":2,
226 | "cost":2
227 | },
228 | {
229 | "user":7163185791,
230 | "other":7187432175,
231 | "direction":"Outgoing",
232 | "duration":8,
233 | "timestamp":"Tue Sep 14 15:55:01 +0100 2010",
234 | "antenna_id":2,
235 | "cost":2
236 | },
237 | {
238 | "user":7163185791,
239 | "other":8704500768,
240 | "direction":"Missed",
241 | "duration":0,
242 | "timestamp":"Wed Sep 15 11:52:36 +0100 2010",
243 | "antenna_id":2,
244 | "cost":0
245 | },
246 | {
247 | "user":7163185791,
248 | "other":8704500768,
249 | "direction":"Missed",
250 | "duration":0,
251 | "timestamp":"Wed Sep 15 12:34:27 +0100 2010",
252 | "antenna_id":2,
253 | "cost":0
254 | },
255 | {
256 | "user":7163185791,
257 | "other":7187432175,
258 | "direction":"Outgoing",
259 | "duration":8,
260 | "timestamp":"Wed Sep 15 15:54:26 +0100 2010",
261 | "antenna_id":2,
262 | "cost":2
263 | },
264 | {
265 | "user":7110730864,
266 | "other":7209670163,
267 | "direction":"Outgoing",
268 | "duration":0,
269 | "timestamp":"Thu Sep 09 18:16:47 +0100 2010",
270 | "antenna_id":1,
271 | "cost":0
272 | },
273 | {
274 | "user":7110730864,
275 | "other":7209670163,
276 | "direction":"Missed",
277 | "duration":0,
278 | "timestamp":"Thu Sep 09 18:37:05 +0100 2010",
279 | "antenna_id":2,
280 | "cost":0
281 | },
282 | {
283 | "user":7110730864,
284 | "other":7209670163,
285 | "direction":"Missed",
286 | "duration":0,
287 | "timestamp":"Thu Sep 09 19:03:05 +0100 2010",
288 | "antenna_id":2,
289 | "cost":0
290 | },
291 | {
292 | "user":7110730864,
293 | "other":4.88e+31,
294 | "direction":"Outgoing",
295 | "duration":0,
296 | "timestamp":"Thu Sep 09 20:02:16 +0100 2010",
297 | "antenna_id":2,
298 | "cost":0
299 | },
300 | {
301 | "user":7110730864,
302 | "other":7209670163,
303 | "direction":"Missed",
304 | "duration":0,
305 | "timestamp":"Thu Sep 09 20:57:51 +0100 2010",
306 | "antenna_id":3,
307 | "cost":0
308 | },
309 | {
310 | "user":7110730864,
311 | "other":4.88e+31,
312 | "direction":"Outgoing",
313 | "duration":0,
314 | "timestamp":"Thu Sep 09 22:07:39 +0100 2010",
315 | "antenna_id":3,
316 | "cost":0
317 | },
318 | {
319 | "user":7110730864,
320 | "other":4.88e+31,
321 | "direction":"Outgoing",
322 | "duration":0,
323 | "timestamp":"Thu Sep 09 22:08:08 +0100 2010",
324 | "antenna_id":3,
325 | "cost":0
326 | },
327 | {
328 | "user":7110730864,
329 | "other":7209670163,
330 | "direction":"Outgoing",
331 | "duration":215,
332 | "timestamp":"Thu Sep 09 22:12:01 +0100 2010",
333 | "antenna_id":2,
334 | "cost":8
335 | },
336 | {
337 | "user":7110730864,
338 | "other":452,
339 | "direction":"Outgoing",
340 | "duration":41,
341 | "timestamp":"Thu Sep 09 22:38:09 +0100 2010",
342 | "antenna_id":2,
343 | "cost":2
344 | },
345 | {
346 | "user":7110730864,
347 | "other":563,
348 | "direction":"Outgoing",
349 | "duration":0,
350 | "timestamp":"Thu Sep 09 23:02:56 +0100 2010",
351 | "antenna_id":2,
352 | "cost":0
353 | },
354 | {
355 | "user":7110730864,
356 | "other":7501874156,
357 | "direction":"Outgoing",
358 | "duration":0,
359 | "timestamp":"Thu Sep 09 23:18:13 +0100 2010",
360 | "antenna_id":2,
361 | "cost":0
362 | },
363 | {
364 | "user":7110730864,
365 | "other":7784425582,
366 | "direction":"Outgoing",
367 | "duration":0,
368 | "timestamp":"Thu Sep 09 23:21:05 +0100 2010",
369 | "antenna_id":2,
370 | "cost":0
371 | },
372 | {
373 | "user":7110730864,
374 | "other":452,
375 | "direction":"Outgoing",
376 | "duration":4,
377 | "timestamp":"Thu Sep 09 23:28:24 +0100 2010",
378 | "antenna_id":2,
379 | "cost":2
380 | },
381 | {
382 | "user":7110730864,
383 | "other":452,
384 | "direction":"Outgoing",
385 | "duration":52,
386 | "timestamp":"Fri Sep 10 06:01:27 +0100 2010",
387 | "antenna_id":1,
388 | "cost":2
389 | },
390 | {
391 | "user":7110730864,
392 | "other":7209670163,
393 | "direction":"Outgoing",
394 | "duration":0,
395 | "timestamp":"Fri Sep 10 06:04:43 +0100 2010",
396 | "antenna_id":2,
397 | "cost":0
398 | },
399 | {
400 | "user":7110730864,
401 | "other":452,
402 | "direction":"Outgoing",
403 | "duration":39,
404 | "timestamp":"Fri Sep 10 07:45:52 +0100 2010",
405 | "antenna_id":4,
406 | "cost":2
407 | },
408 | {
409 | "user":7110730864,
410 | "other":7681546436,
411 | "direction":"Missed",
412 | "duration":0,
413 | "timestamp":"Fri Sep 10 07:53:09 +0100 2010",
414 | "antenna_id":2,
415 | "cost":0
416 | },
417 | {
418 | "user":7110730864,
419 | "other":7681546436,
420 | "direction":"Outgoing",
421 | "duration":0,
422 | "timestamp":"Fri Sep 10 07:54:02 +0100 2010",
423 | "antenna_id":1,
424 | "cost":0
425 | },
426 | {
427 | "user":7110730864,
428 | "other":7914559382,
429 | "direction":"Outgoing",
430 | "duration":0,
431 | "timestamp":"Fri Sep 10 11:15:49 +0100 2010",
432 | "antenna_id":10,
433 | "cost":0
434 | },
435 | {
436 | "user":7110730864,
437 | "other":1258345846,
438 | "direction":"Missed",
439 | "duration":0,
440 | "timestamp":"Fri Sep 10 19:35:57 +0100 2010",
441 | "antenna_id":1,
442 | "cost":0
443 | }
444 | ]
445 | }
--------------------------------------------------------------------------------
/cellyzer_gui/test/test.py:
--------------------------------------------------------------------------------
1 | from selenium import webdriver
2 | from selenium.webdriver.common.keys import Keys
3 | from selenium .webdriver.common.by import By
4 | from selenium.webdriver.support.ui import WebDriverWait
5 | from selenium.webdriver.support.ui import Select
6 | from selenium.webdriver.support import expected_conditions as EC
7 | import time
8 |
9 |
10 | chromedriver= "chromedriver"
11 | driver = webdriver.Chrome(chromedriver)
12 | driver.get("http://127.0.0.1:8050")
13 |
14 | element = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "add-cell-records-dataset")))
15 | element.click()
16 | driver.refresh()
17 |
18 | call = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "call_card")))
19 | call.click()
20 | time.sleep(2)
21 |
22 | ####### add call dataset
23 | call_name = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, "input[type='file']")))
24 | call_name.send_keys("D:\\SE Project sem5\\cellyzer-gui-pip\\test\\calls.csv")
25 | time.sleep(1.5)
26 | choose_call = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "upload-data_call")))
27 | choose_call.send_keys("Call")
28 | add_call = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "adding_call")))
29 | add_call.click()
30 | time.sleep(2)
31 |
32 | ###### go to dataset page after adding call dataset
33 | go_dataset_page = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "add-cell-records-dataset")))
34 | go_dataset_page.click()
35 | driver.refresh()
36 |
37 | #### visit "Call" call dataset
38 | visit_call = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "Call")))
39 | visit_call.click()
40 | time.sleep(2)
41 |
42 | #### show call data
43 | show_call = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_show_call")))
44 | show_call.click()
45 | driver.refresh()
46 | call_head = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "call_head")))
47 | call_head.send_keys(20)
48 | call_tail = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "call_tail")))
49 | call_tail.send_keys(20)
50 | view_call_data = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "view")))
51 | view_call_data.click()
52 | time.sleep(3)
53 | driver.execute_script("window.history.go(-1)")
54 | # driver.refresh()
55 | time.sleep(2)
56 |
57 | ##### show all call users
58 | call_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_call_users")))
59 | call_users.click()
60 | driver.refresh()
61 | view_call_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "get_users")))
62 | view_call_users.click()
63 | time.sleep(3)
64 | driver.execute_script("window.history.go(-1)")
65 | # driver.refresh()
66 | time.sleep(2)
67 |
68 | # ##### show connected users for given input
69 | # connected_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_call_connected")))
70 | # connected_users.click()
71 | # select_user_call_conn = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "but_select_user")))
72 | # select_user_call_conn.click()
73 | # input1 = WebDriverWait(driver, 10000).until(EC.presence_of_element_located((By.CSS_SELECTOR, "input[id='search']")))
74 | # input1.send_keys("8d27cf2694")
75 | # get_connected_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "connected_users")))
76 | # get_connected_users.click()
77 | # driver.execute_script("window.history.go(-1)")
78 | # driver.refresh()
79 |
80 | # ###### show call record between 2 users
81 | # call_record_2_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_call_records")))
82 | # call_record_2_users.click()
83 | # select_user_call_2user = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "select_user_records_2_user")))
84 | # select_user_call_2user.click()
85 | # call_record_input1 = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "search_2")))
86 | # call_record_input1.send_keys("8d27cf2694")
87 | # call_record_input2 = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "search_3")))
88 | # call_record_input2.send_keys("7187432175")
89 | # get_call_record_2_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "record_users")))
90 | # get_call_record_2_users.click()
91 | # driver.execute_script("window.history.go(-1)")
92 | # driver.refresh()
93 |
94 | # ###### show close contacts for given input
95 | # close_contacts = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_call_close")))
96 | # close_contacts.click()
97 | # select_user_close_contact = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "select_user_close_contact")))
98 | # select_user_close_contact.click()
99 | # close_contacts_input1 = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "user_3")))
100 | # close_contacts_input1.send_keys("8d27cf2694")
101 | # close_contacts_input2 = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "contact")))
102 | # close_contacts_input2.send_keys("2")
103 | # get_close_contacts = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "close_contacts")))
104 | # get_close_contacts.click()
105 | # driver.execute_script("window.history.go(-1)")
106 | # driver.refresh()
107 |
108 | # ##### show ignored calls
109 | # ignored_call = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_ignored_call")))
110 | # ignored_call.click()
111 | # select_user_ignored_call = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "select_user_ignore_call")))
112 | # select_user_ignored_call.click()
113 | # ignored_call_input = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "user_5")))
114 | # ignored_call_input.send_keys("8d27cf2694")
115 | # get_ignored_call = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "ignore_call")))
116 | # get_ignored_call.click()
117 | # driver.execute_script("window.history.go(-1)")
118 | # driver.refresh()
119 |
120 | # ##### show active time of user
121 | # active_time = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_active_time")))
122 | # active_time.click()
123 | # select_user_active_time = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "select_user_active_time")))
124 | # select_user_active_time.click()
125 | # active_time_input = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "user_4")))
126 | # active_time_input.send_keys("8d27cf2694")
127 | # get_active_time = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "active_time")))
128 | # get_active_time.click()
129 | # driver.execute_script("window.history.go(-1)")
130 | # driver.refresh()
131 |
132 | ##### visualize connection between all call users
133 | visualize_connection = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_call_visu_connection")))
134 | visualize_connection.click()
135 | driver.refresh()
136 | # select_user_call_visu_conn = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "select_user_visu_conn")))
137 | # select_user_call_visu_conn.click()
138 | view_visualize_connection = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visualize_connection")))
139 | view_visualize_connection.click()
140 | time.sleep(8)
141 |
142 | ##### go to dataset page after visualize connection of call users
143 | element = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "add-cell-records-dataset")))
144 | element.click()
145 | driver.refresh()
146 |
147 | ################################
148 | message = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "message_card")))
149 | message.click()
150 | time.sleep(2)
151 |
152 | ####### add message dataset
153 | message_name = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, "input[type='file']")))
154 | message_name.send_keys("D:\\SE Project sem5\\cellyzer-gui-pip\\test\\messages.csv")
155 | time.sleep(1.5)
156 | choose_message = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "upload-data_message")))
157 | choose_message.send_keys("Message")
158 | add_message = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "adding_message")))
159 | add_message.click()
160 | time.sleep(2)
161 |
162 | ###### go to dataset page after adding message dataset
163 | go_dataset_page_message = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "add-cell-records-dataset")))
164 | go_dataset_page_message.click()
165 | driver.refresh()
166 |
167 | #### visit "Message" message dataset
168 | visit_message = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "Message")))
169 | visit_message.click()
170 | driver.refresh()
171 | time.sleep(2)
172 |
173 | #### show message data
174 | show_message = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_message_data")))
175 | show_message.click()
176 | driver.refresh()
177 | msg_head = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "msg_head")))
178 | msg_head.send_keys(20)
179 | msg_tail = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "msg_tail")))
180 | msg_tail.send_keys(20)
181 | view_message_data = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "view_message")))
182 | view_message_data.click()
183 | time.sleep(3)
184 | driver.execute_script("window.history.go(-1)")
185 | # driver.refresh()
186 | time.sleep(2)
187 |
188 | ##### show all message users
189 | message_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_message_users")))
190 | message_users.click()
191 | driver.refresh()
192 | view_message_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "get_message_users")))
193 | view_message_users.click()
194 | time.sleep(3)
195 | driver.execute_script("window.history.go(-1)")
196 | # driver.refresh()
197 | time.sleep(2)
198 |
199 | # ###### show message record between 2 users
200 | # message_record_2_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_message_records_2")))
201 | # message_record_2_users.click()
202 | # message_record_input1 = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "message_user2")))
203 | # message_record_input1.send_keys("7681546436")
204 | # message_record_input2 = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "message_user3")))
205 | # message_record_input2.send_keys("7641036117")
206 | # get_message_record_2_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "record_message_users")))
207 | # get_message_record_2_users.click()
208 | # driver.execute_script("window.history.go(-1)")
209 |
210 | ##### visualize connection between all message users
211 | visu_conn_message = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_message_visualization")))
212 | visu_conn_message.click()
213 | driver.refresh()
214 | view_visu_conn_message = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visualize_message_connection")))
215 | view_visu_conn_message.click()
216 | time.sleep(8)
217 | driver.execute_script("window.history.go(-1)")
218 | # driver.refresh()
219 | time.sleep(2)
220 |
221 | # ##### show connected message users for given input
222 | # connected_message_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_message_connected")))
223 | # connected_message_users.click()
224 | # select_msg_user_call_conn = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "select_msg_user_connected")))
225 | # select_msg_user_call_conn.click()
226 | # input_message = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, "input[id='user_message']")))
227 | # input_message.send_keys("8d27cf2694")
228 | # get_connected_message_users = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "connected_message_users")))
229 | # get_connected_message_users.click()
230 | # driver.execute_script("window.history.go(-1)")
231 | # driver.refresh()
232 |
233 | element = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "add-cell-records-dataset")))
234 | element.click()
235 |
236 | #############################
237 | cell = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "cell_card")))
238 | cell.click()
239 |
240 | ####### add cell dataset
241 | cell_name = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, "input[type='file']")))
242 | cell_name.send_keys("D:\\SE Project sem5\\cellyzer-gui-pip\\test\\antennas.csv")
243 | time.sleep(2)
244 | choose_cell = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "upload-data_cell")))
245 | choose_cell.send_keys("Cell")
246 | choose_call_cell = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, "input[id='select_call']")))
247 | choose_call_cell.send_keys("Call")
248 | time.sleep(1)
249 | add_cell = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "show_cell_dash")))
250 | add_cell.click()
251 | # choose_call_cell = Select(WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "select_call"))))
252 | # choose_call_cell.select_by_visible_text('Call')
253 |
254 |
255 | # #### visit "Cell" cell dataset
256 | # visit_cell = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "Cell")))
257 | # visit_cell.click()
258 |
259 | # #### show cell data
260 | # show_cell = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_cell_data")))
261 | # show_cell.click()
262 | # view_cell_data = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "view_cell")))
263 | # view_cell_data.click()
264 | # driver.execute_script("window.history.go(-1)")
265 |
266 | # ##### show cell record id
267 | # cell_id = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_cell_id")))
268 | # cell_id.click()
269 | # input_cell_id = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "cell_id")))
270 | # input_cell_id.send_keys("2")
271 | # view_cell_id = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "records_cell")))
272 | # view_cell_id.click()
273 | # driver.execute_script("window.history.go(-1)")
274 |
275 | # ##### show population visualize
276 | # population_visualize = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_population")))
277 | # population_visualize.click()
278 | # get_population = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "population_button")))
279 | # get_population.click()
280 | # driver.execute_script("window.history.go(-1)")
281 |
282 | # ##### show trip visualization of given input
283 | # trip_visualization = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "visu_trip_visualization")))
284 | # trip_visualization.click()
285 | # trip_user = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "trip_user")))
286 | # trip_user.send_keys("7681546436")
287 | # get_trip_visualization = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "trip_visualize_button")))
288 | # get_trip_visualization.click()
289 | # driver.execute_script("window.history.go(-1)")
--------------------------------------------------------------------------------
/demo/.ipynb_checkpoints/demo_user_notebook-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": true
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "Requirement already satisfied: xlrd in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (1.2.0)\n"
15 | ]
16 | },
17 | {
18 | "name": "stderr",
19 | "output_type": "stream",
20 | "text": [
21 | "You are using pip version 10.0.1, however version 20.0.2 is available.\n",
22 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
23 | ]
24 | },
25 | {
26 | "name": "stdout",
27 | "output_type": "stream",
28 | "text": [
29 | "Requirement already satisfied: numpy in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (1.18.2)\n"
30 | ]
31 | },
32 | {
33 | "name": "stderr",
34 | "output_type": "stream",
35 | "text": [
36 | "You are using pip version 10.0.1, however version 20.0.2 is available.\n",
37 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
38 | ]
39 | },
40 | {
41 | "name": "stdout",
42 | "output_type": "stream",
43 | "text": [
44 | "Requirement already satisfied: tabulate in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (0.8.7)\n"
45 | ]
46 | },
47 | {
48 | "name": "stderr",
49 | "output_type": "stream",
50 | "text": [
51 | "You are using pip version 10.0.1, however version 20.0.2 is available.\n",
52 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
53 | ]
54 | },
55 | {
56 | "name": "stdout",
57 | "output_type": "stream",
58 | "text": [
59 | "Requirement already satisfied: datetime in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (4.3)\n",
60 | "Requirement already satisfied: zope.interface in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from datetime) (5.1.0)\n",
61 | "Requirement already satisfied: pytz in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from datetime) (2019.3)\n",
62 | "Requirement already satisfied: setuptools in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from zope.interface->datetime) (39.0.1)\n"
63 | ]
64 | },
65 | {
66 | "name": "stderr",
67 | "output_type": "stream",
68 | "text": [
69 | "You are using pip version 10.0.1, however version 20.0.2 is available.\n",
70 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
71 | ]
72 | },
73 | {
74 | "name": "stdout",
75 | "output_type": "stream",
76 | "text": [
77 | "Requirement already satisfied: networkx in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (2.4)\n",
78 | "Requirement already satisfied: decorator>=4.3.0 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from networkx) (4.4.2)\n"
79 | ]
80 | },
81 | {
82 | "name": "stderr",
83 | "output_type": "stream",
84 | "text": [
85 | "You are using pip version 10.0.1, however version 20.0.2 is available.\n",
86 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
87 | ]
88 | },
89 | {
90 | "name": "stdout",
91 | "output_type": "stream",
92 | "text": [
93 | "Requirement already satisfied: matplotlib in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (3.2.1)\n",
94 | "Requirement already satisfied: cycler>=0.10 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from matplotlib) (0.10.0)\n",
95 | "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from matplotlib) (2.4.6)"
96 | ]
97 | },
98 | {
99 | "name": "stderr",
100 | "output_type": "stream",
101 | "text": [
102 | "You are using pip version 10.0.1, however version 20.0.2 is available.\n",
103 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
104 | ]
105 | },
106 | {
107 | "name": "stdout",
108 | "output_type": "stream",
109 | "text": [
110 | "\n",
111 | "Requirement already satisfied: python-dateutil>=2.1 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from matplotlib) (2.8.1)\n",
112 | "Requirement already satisfied: kiwisolver>=1.0.1 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from matplotlib) (1.1.0)\n",
113 | "Requirement already satisfied: numpy>=1.11 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from matplotlib) (1.18.2)\n",
114 | "Requirement already satisfied: six in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from cycler>=0.10->matplotlib) (1.14.0)\n",
115 | "Requirement already satisfied: setuptools in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from kiwisolver>=1.0.1->matplotlib) (39.0.1)\n",
116 | "Requirement already satisfied: folium in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (0.10.1)\n",
117 | "Requirement already satisfied: branca>=0.3.0 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from folium) (0.4.0)\n",
118 | "Requirement already satisfied: requests in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from folium) (2.23.0)\n",
119 | "Requirement already satisfied: numpy in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from folium) (1.18.2)\n",
120 | "Requirement already satisfied: jinja2>=2.9 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from folium) (2.11.1)\n",
121 | "Requirement already satisfied: six in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from branca>=0.3.0->folium) (1.14.0)\n",
122 | "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from requests->folium) (1.25.8)\n",
123 | "Requirement already satisfied: idna<3,>=2.5 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from requests->folium) (2.9)\n",
124 | "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from requests->folium) (2020.4.5.1)\n",
125 | "Requirement already satisfied: chardet<4,>=3.0.2 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from requests->folium) (3.0.4)\n",
126 | "Requirement already satisfied: MarkupSafe>=0.23 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from jinja2>=2.9->folium) (1.1.1)\n"
127 | ]
128 | },
129 | {
130 | "name": "stderr",
131 | "output_type": "stream",
132 | "text": [
133 | "You are using pip version 10.0.1, however version 20.0.2 is available.\n",
134 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
135 | ]
136 | }
137 | ],
138 | "source": [
139 | "!pip install xlrd\n",
140 | "!pip install numpy\n",
141 | "!pip install tabulate\n",
142 | "!pip install datetime \n",
143 | "!pip install networkx\n",
144 | "!pip install matplotlib\n",
145 | "!pip install folium"
146 | ]
147 | },
148 | {
149 | "cell_type": "markdown",
150 | "metadata": {},
151 | "source": [
152 | "# import Cellyzer"
153 | ]
154 | },
155 | {
156 | "cell_type": "code",
157 | "execution_count": 1,
158 | "metadata": {},
159 | "outputs": [],
160 | "source": [
161 | "import sys\n",
162 | "import os\n",
163 | "\n",
164 | "module_path = os.path.abspath(os.path.join('..'))\n",
165 | "if module_path not in sys.path:\n",
166 | " sys.path.append(module_path)\n",
167 | "\n",
168 | "import cellyzer as cz"
169 | ]
170 | },
171 | {
172 | "cell_type": "markdown",
173 | "metadata": {},
174 | "source": [
175 | "# read call data and cell data sets"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": 2,
181 | "metadata": {},
182 | "outputs": [
183 | {
184 | "name": "stdout",
185 | "output_type": "stream",
186 | "text": [
187 | "[x] Reading Call Data\n",
188 | "[x] Objects creation successful\n",
189 | "\n"
190 | ]
191 | }
192 | ],
193 | "source": [
194 | "call_file_path = \"dataset/my_test_data/calls.csv\"\n",
195 | "antenna_file_path = \"dataset/my_test_data/antennas.csv\"\n",
196 | "\n",
197 | "callDataSet = cz.read_call(call_file_path)\n",
198 | "cellDataSet = cz.read_cell(antenna_file_path)"
199 | ]
200 | },
201 | {
202 | "cell_type": "markdown",
203 | "metadata": {},
204 | "source": [
205 | "# User objects"
206 | ]
207 | },
208 | {
209 | "cell_type": "code",
210 | "execution_count": 3,
211 | "metadata": {},
212 | "outputs": [],
213 | "source": [
214 | "user_number = \"3e97992791\"\n",
215 | "user2_number = \"8d27cf2694\""
216 | ]
217 | },
218 | {
219 | "cell_type": "code",
220 | "execution_count": 4,
221 | "metadata": {},
222 | "outputs": [],
223 | "source": [
224 | "user1 = cz.User(callDataSet=callDataSet, cellDataSet=cellDataSet, contact_no=user_number)"
225 | ]
226 | },
227 | {
228 | "cell_type": "markdown",
229 | "metadata": {},
230 | "source": [
231 | "# get user home and work locations"
232 | ]
233 | },
234 | {
235 | "cell_type": "code",
236 | "execution_count": 5,
237 | "metadata": {},
238 | "outputs": [
239 | {
240 | "name": "stdout",
241 | "output_type": "stream",
242 | "text": [
243 | ">> home location : [42.304917, -71.147374]\n",
244 | ">> home location -> cell id : 10\n"
245 | ]
246 | }
247 | ],
248 | "source": [
249 | "location_home = user1.get_home_location()\n",
250 | "print('>> home location : ', location_home)\n",
251 | "home_cell_id = user1.get_home_location_related_cell_id()\n",
252 | "print(\">> home location -> cell id : \", home_cell_id)"
253 | ]
254 | },
255 | {
256 | "cell_type": "code",
257 | "execution_count": 6,
258 | "metadata": {},
259 | "outputs": [
260 | {
261 | "name": "stdout",
262 | "output_type": "stream",
263 | "text": [
264 | ">> work location : [42.386722, -71.138778]\n",
265 | ">> work location -> cell id : 2\n"
266 | ]
267 | }
268 | ],
269 | "source": [
270 | "location_office = user1.get_work_location()\n",
271 | "print('>> work location : ', location_office)\n",
272 | "officeplace_cell_id = user1.get_work_location_related_cell_id()\n",
273 | "print(\">> work location -> cell id : \", officeplace_cell_id)"
274 | ]
275 | },
276 | {
277 | "cell_type": "code",
278 | "execution_count": 7,
279 | "metadata": {},
280 | "outputs": [
281 | {
282 | "data": {
283 | "text/html": [
284 | ""
285 | ],
286 | "text/plain": [
287 | ""
288 | ]
289 | },
290 | "execution_count": 7,
291 | "metadata": {},
292 | "output_type": "execute_result"
293 | }
294 | ],
295 | "source": [
296 | "cz.visualization.view_home_work_locations(home_location=location_home, work_location=location_office , notebook = True)"
297 | ]
298 | },
299 | {
300 | "cell_type": "markdown",
301 | "metadata": {},
302 | "source": [
303 | "# get ignored calls of the user"
304 | ]
305 | },
306 | {
307 | "cell_type": "code",
308 | "execution_count": 8,
309 | "metadata": {},
310 | "outputs": [],
311 | "source": [
312 | "user3_number = '329233d117'\n",
313 | "user3 = cz.User(callDataSet=callDataSet, cellDataSet=cellDataSet, contact_no=user3_number)"
314 | ]
315 | },
316 | {
317 | "cell_type": "code",
318 | "execution_count": 9,
319 | "metadata": {},
320 | "outputs": [
321 | {
322 | "name": "stdout",
323 | "output_type": "stream",
324 | "text": [
325 | ">> ignored calls details : \n",
326 | "[{'other user': '0041628436', 'date': '11-02-1980', 'time stamp': '08:06:18', 'cell ID': '5'}]\n"
327 | ]
328 | }
329 | ],
330 | "source": [
331 | "ignored_call_details = user3.get_ignored_call_details()\n",
332 | "print(\">> ignored calls details : \")\n",
333 | "print(ignored_call_details)"
334 | ]
335 | },
336 | {
337 | "cell_type": "code",
338 | "execution_count": 10,
339 | "metadata": {},
340 | "outputs": [
341 | {
342 | "name": "stdout",
343 | "output_type": "stream",
344 | "text": [
345 | "+------------+------------+------------+---------+\n",
346 | "| other user | date | time stamp | cell ID |\n",
347 | "+------------+------------+------------+---------+\n",
348 | "| 0041628436 | 11-02-1980 | 08:06:18 | 5 |\n",
349 | "+------------+------------+------------+---------+\n"
350 | ]
351 | }
352 | ],
353 | "source": [
354 | "cz.utils.tabulate_list_of_dictionaries(ignored_call_details)"
355 | ]
356 | },
357 | {
358 | "cell_type": "code",
359 | "execution_count": null,
360 | "metadata": {},
361 | "outputs": [],
362 | "source": []
363 | }
364 | ],
365 | "metadata": {
366 | "kernelspec": {
367 | "display_name": "Python 3",
368 | "language": "python",
369 | "name": "python3"
370 | },
371 | "language_info": {
372 | "codemirror_mode": {
373 | "name": "ipython",
374 | "version": 3
375 | },
376 | "file_extension": ".py",
377 | "mimetype": "text/x-python",
378 | "name": "python",
379 | "nbconvert_exporter": "python",
380 | "pygments_lexer": "ipython3",
381 | "version": "3.7.0"
382 | }
383 | },
384 | "nbformat": 4,
385 | "nbformat_minor": 4
386 | }
387 |
--------------------------------------------------------------------------------
/demo/.ipynb_checkpoints/demo_msg_data_notebook-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {},
7 | "outputs": [
8 | {
9 | "name": "stdout",
10 | "output_type": "stream",
11 | "text": [
12 | "Requirement already satisfied: xlrd in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (1.2.0)\n"
13 | ]
14 | },
15 | {
16 | "name": "stderr",
17 | "output_type": "stream",
18 | "text": [
19 | "You are using pip version 10.0.1, however version 20.1b1 is available.\n",
20 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n",
21 | "You are using pip version 10.0.1, however version 20.1b1 is available.\n",
22 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
23 | ]
24 | },
25 | {
26 | "name": "stdout",
27 | "output_type": "stream",
28 | "text": [
29 | "Requirement already satisfied: numpy in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (1.18.2)\n",
30 | "Requirement already satisfied: tabulate in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (0.8.7)\n"
31 | ]
32 | },
33 | {
34 | "name": "stderr",
35 | "output_type": "stream",
36 | "text": [
37 | "You are using pip version 10.0.1, however version 20.1b1 is available.\n",
38 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
39 | ]
40 | },
41 | {
42 | "name": "stdout",
43 | "output_type": "stream",
44 | "text": [
45 | "Requirement already satisfied: datetime in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (4.3)\n",
46 | "Requirement already satisfied: zope.interface in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from datetime) (5.1.0)\n",
47 | "Requirement already satisfied: pytz in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from datetime) (2019.3)\n",
48 | "Requirement already satisfied: setuptools in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from zope.interface->datetime) (39.0.1)\n"
49 | ]
50 | },
51 | {
52 | "name": "stderr",
53 | "output_type": "stream",
54 | "text": [
55 | "You are using pip version 10.0.1, however version 20.1b1 is available.\n",
56 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
57 | ]
58 | },
59 | {
60 | "name": "stdout",
61 | "output_type": "stream",
62 | "text": [
63 | "Requirement already satisfied: networkx in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (2.4)\n",
64 | "Requirement already satisfied: decorator>=4.3.0 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from networkx) (4.4.2)\n"
65 | ]
66 | },
67 | {
68 | "name": "stderr",
69 | "output_type": "stream",
70 | "text": [
71 | "You are using pip version 10.0.1, however version 20.1b1 is available.\n",
72 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
73 | ]
74 | },
75 | {
76 | "name": "stdout",
77 | "output_type": "stream",
78 | "text": [
79 | "Requirement already satisfied: matplotlib in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (3.2.1)\n",
80 | "Requirement already satisfied: numpy>=1.11 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from matplotlib) (1.18.2)\n",
81 | "Requirement already satisfied: python-dateutil>=2.1 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from matplotlib) (2.8.1)\n",
82 | "Requirement already satisfied: kiwisolver>=1.0.1 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from matplotlib) (1.1.0)\n",
83 | "Requirement already satisfied: cycler>=0.10 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from matplotlib) (0.10.0)\n",
84 | "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from matplotlib) (2.4.6)\n",
85 | "Requirement already satisfied: six>=1.5 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from python-dateutil>=2.1->matplotlib) (1.14.0)\n",
86 | "Requirement already satisfied: setuptools in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from kiwisolver>=1.0.1->matplotlib) (39.0.1)\n"
87 | ]
88 | },
89 | {
90 | "name": "stderr",
91 | "output_type": "stream",
92 | "text": [
93 | "You are using pip version 10.0.1, however version 20.1b1 is available.\n",
94 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n",
95 | "You are using pip version 10.0.1, however version 20.1b1 is available.\n",
96 | "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
97 | ]
98 | },
99 | {
100 | "name": "stdout",
101 | "output_type": "stream",
102 | "text": [
103 | "Requirement already satisfied: folium in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (0.10.1)\n",
104 | "Requirement already satisfied: numpy in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from folium) (1.18.2)\n",
105 | "Requirement already satisfied: requests in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from folium) (2.23.0)\n",
106 | "Requirement already satisfied: jinja2>=2.9 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from folium) (2.11.1)\n",
107 | "Requirement already satisfied: branca>=0.3.0 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from folium) (0.4.0)\n",
108 | "Requirement already satisfied: chardet<4,>=3.0.2 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from requests->folium) (3.0.4)\n",
109 | "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from requests->folium) (1.25.8)\n",
110 | "Requirement already satisfied: idna<3,>=2.5 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from requests->folium) (2.9)\n",
111 | "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from requests->folium) (2020.4.5.1)\n",
112 | "Requirement already satisfied: MarkupSafe>=0.23 in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from jinja2>=2.9->folium) (1.1.1)\n",
113 | "Requirement already satisfied: six in c:\\users\\wageeshabangamuarach\\appdata\\local\\programs\\python\\python37\\lib\\site-packages (from branca>=0.3.0->folium) (1.14.0)\n"
114 | ]
115 | }
116 | ],
117 | "source": [
118 | "!pip install xlrd\n",
119 | "!pip install numpy\n",
120 | "!pip install tabulate\n",
121 | "!pip install datetime \n",
122 | "!pip install networkx\n",
123 | "!pip install matplotlib\n",
124 | "!pip install folium"
125 | ]
126 | },
127 | {
128 | "cell_type": "markdown",
129 | "metadata": {},
130 | "source": [
131 | "# import Cellyzer"
132 | ]
133 | },
134 | {
135 | "cell_type": "code",
136 | "execution_count": 2,
137 | "metadata": {},
138 | "outputs": [],
139 | "source": [
140 | "import sys\n",
141 | "import os\n",
142 | "\n",
143 | "module_path = os.path.abspath(os.path.join('..'))\n",
144 | "if module_path not in sys.path:\n",
145 | " sys.path.append(module_path)\n",
146 | "\n",
147 | "import cellyzer as cz"
148 | ]
149 | },
150 | {
151 | "cell_type": "markdown",
152 | "metadata": {},
153 | "source": [
154 | "# read message data csv file"
155 | ]
156 | },
157 | {
158 | "cell_type": "code",
159 | "execution_count": 3,
160 | "metadata": {},
161 | "outputs": [
162 | {
163 | "name": "stdout",
164 | "output_type": "stream",
165 | "text": [
166 | "[x] Reading Message Data...\n",
167 | "[x] Objects creation successful\n",
168 | "\n"
169 | ]
170 | },
171 | {
172 | "name": "stderr",
173 | "output_type": "stream",
174 | "text": [
175 | "\u001b[33mWarning: 2 record(s) were removed due to missing or incomplete fields.\n",
176 | " direction: 2 record(s) with incomplete values\n",
177 | " length: 2 record(s) with incomplete values\n",
178 | " timestamp: 2 record(s) with incomplete values\n",
179 | "\u001b[0m"
180 | ]
181 | }
182 | ],
183 | "source": [
184 | "msg_file_path = \"dataset/my_test_data/messages.csv\"\n",
185 | "messageDataSet = cz.read_msg(msg_file_path)"
186 | ]
187 | },
188 | {
189 | "cell_type": "markdown",
190 | "metadata": {},
191 | "source": [
192 | "# print data set"
193 | ]
194 | },
195 | {
196 | "cell_type": "code",
197 | "execution_count": 4,
198 | "metadata": {
199 | "scrolled": true
200 | },
201 | "outputs": [
202 | {
203 | "name": "stdout",
204 | "output_type": "stream",
205 | "text": [
206 | "\n",
207 | " >>> Message Dataset :\n",
208 | "+----+------------+-------------+------------+---------+--------------------------------+\n",
209 | "| | _user | _other_user | _direction | _length | _timestamp |\n",
210 | "+----+------------+-------------+------------+---------+--------------------------------+\n",
211 | "| 1 | 8d27cf2694 | 78c4ca6671 | Incoming | 28 | Wed Sep 15 19:01:54 +0100 2010 |\n",
212 | "| 2 | 329233d117 | 0041628436 | Incoming | 7 | Mon Feb 11 07:08:49 +0000 1980 |\n",
213 | "| 3 | 329233d117 | 0041628436 | Outgoing | 6 | Mon Feb 11 07:14:05 +0000 1980 |\n",
214 | "| 4 | 329233d117 | bac412f897 | Outgoing | 41 | Thu Sep 09 21:43:44 +0100 2010 |\n",
215 | "| 5 | bac412f897 | 322692e582 | Outgoing | 75 | Mon Jan 07 22:58:28 +0000 1980 |\n",
216 | "| 6 | bac412f897 | 322692e582 | Incoming | 33 | Thu Sep 09 18:53:25 +0100 2010 |\n",
217 | "| 7 | bac412f897 | 322692e582 | Outgoing | 90 | Thu Sep 09 18:59:35 +0100 2010 |\n",
218 | "| 8 | bac412f897 | 322692e582 | Incoming | 30 | Thu Sep 09 19:06:06 +0100 2010 |\n",
219 | "| 9 | bac412f897 | 322692e582 | Outgoing | 112 | Thu Sep 09 19:22:28 +0100 2010 |\n",
220 | "| 10 | bac412f897 | 322692e582 | Incoming | 89 | Thu Sep 09 19:24:50 +0100 2010 |\n",
221 | "| 11 | bac412f897 | 322692e582 | Outgoing | 28 | Thu Sep 09 19:26:17 +0100 2010 |\n",
222 | "| 12 | bac412f897 | 322692e582 | Incoming | 19 | Thu Sep 09 19:34:16 +0100 2010 |\n",
223 | "| 13 | bac412f897 | 322692e582 | Incoming | 2 | Thu Sep 09 19:35:07 +0100 2010 |\n",
224 | "| 14 | bac412f897 | 322692e582 | Outgoing | 43 | Thu Sep 09 19:35:45 +0100 2010 |\n",
225 | "| 15 | bac412f897 | 0041628436 | Incoming | 19 | Thu Sep 09 21:31:23 +0100 2010 |\n",
226 | "| 16 | bac412f897 | 0041628436 | Outgoing | 20 | Thu Sep 09 21:32:11 +0100 2010 |\n",
227 | "| 17 | bac412f897 | 0041628436 | Incoming | 34 | Thu Sep 09 21:33:45 +0100 2010 |\n",
228 | "| 18 | bac412f897 | 0041628436 | Outgoing | 2 | Thu Sep 09 21:34:14 +0100 2010 |\n",
229 | "| 19 | bac412f897 | 329233d117 | Incoming | 41 | Thu Sep 09 21:42:55 +0100 2010 |\n",
230 | "| 20 | bac412f897 | 322692e582 | Outgoing | 23 | Fri Sep 10 06:36:57 +0100 2010 |\n",
231 | "| 21 | bac412f897 | 322692e582 | Incoming | 13 | Fri Sep 10 06:38:38 +0100 2010 |\n",
232 | "| 22 | bac412f897 | 322692e582 | Outgoing | 11 | Fri Sep 10 06:39:10 +0100 2010 |\n",
233 | "| 23 | bac412f897 | 322692e582 | Incoming | 15 | Fri Sep 10 06:40:56 +0100 2010 |\n",
234 | "| 24 | bac412f897 | e1ba3ba266 | Incoming | 150 | Fri Sep 10 12:23:21 +0100 2010 |\n",
235 | "| 25 | bac412f897 | ae578bf678 | Incoming | 45 | Fri Sep 10 16:07:38 +0100 2010 |\n",
236 | "| 26 | bac412f897 | 30b785e895 | Incoming | 70 | Fri Sep 10 16:33:49 +0100 2010 |\n",
237 | "| 27 | bac412f897 | 30b785e895 | Outgoing | 58 | Fri Sep 10 16:36:07 +0100 2010 |\n",
238 | "| 28 | bac412f897 | 30b785e895 | Incoming | 9 | Fri Sep 10 16:36:41 +0100 2010 |\n",
239 | "| 29 | bac412f897 | 322692e582 | Outgoing | 14 | Fri Sep 10 16:40:16 +0100 2010 |\n",
240 | "| 30 | bac412f897 | 329233d117 | Incoming | 20 | Fri Sep 10 16:47:21 +0100 2010 |\n",
241 | "| 31 | bac412f897 | 329233d117 | Outgoing | 4 | Fri Sep 10 16:47:45 +0100 2010 |\n",
242 | "| 32 | bac412f897 | 322692e582 | Incoming | 100 | Fri Sep 10 16:47:59 +0100 2010 |\n",
243 | "| 33 | bac412f897 | 322692e582 | Outgoing | 49 | Fri Sep 10 16:49:06 +0100 2010 |\n",
244 | "| 34 | bac412f897 | 322692e582 | Incoming | 159 | Fri Sep 10 16:52:51 +0100 2010 |\n",
245 | "| 35 | bac412f897 | 322692e582 | Outgoing | 86 | Fri Sep 10 16:55:14 +0100 2010 |\n",
246 | "| 36 | bac412f897 | 322692e582 | Incoming | 57 | Fri Sep 10 16:56:42 +0100 2010 |\n",
247 | "| 37 | bac412f897 | 322692e582 | Outgoing | 59 | Fri Sep 10 16:59:18 +0100 2010 |\n",
248 | "| 38 | bac412f897 | 322692e582 | Incoming | 52 | Fri Sep 10 17:00:37 +0100 2010 |\n",
249 | "| 39 | bac412f897 | 322692e582 | Outgoing | 99 | Fri Sep 10 17:02:45 +0100 2010 |\n",
250 | "| 40 | bac412f897 | 322692e582 | Incoming | 82 | Fri Sep 10 17:08:34 +0100 2010 |\n",
251 | "| 41 | bac412f897 | 322692e582 | Outgoing | 71 | Fri Sep 10 17:10:43 +0100 2010 |\n",
252 | "| 42 | bac412f897 | 322692e582 | Incoming | 31 | Fri Sep 10 17:29:15 +0100 2010 |\n",
253 | "| 43 | bac412f897 | 322692e582 | Outgoing | 126 | Fri Sep 10 17:31:56 +0100 2010 |\n",
254 | "| 44 | bac412f897 | 322692e582 | Incoming | 36 | Fri Sep 10 17:38:26 +0100 2010 |\n",
255 | "| 45 | bac412f897 | 322692e582 | Outgoing | 159 | Fri Sep 10 17:41:33 +0100 2010 |\n",
256 | "| 46 | bac412f897 | 322692e582 | Incoming | 40 | Fri Sep 10 17:43:14 +0100 2010 |\n",
257 | "| 47 | bac412f897 | 322692e582 | Outgoing | 74 | Fri Sep 10 17:47:08 +0100 2010 |\n",
258 | "| 48 | bac412f897 | 322692e582 | Incoming | 29 | Fri Sep 10 17:48:28 +0100 2010 |\n",
259 | "| 49 | bac412f897 | 322692e582 | Outgoing | 149 | Fri Sep 10 17:54:40 +0100 2010 |\n",
260 | "+----+------------+-------------+------------+---------+--------------------------------+\n"
261 | ]
262 | }
263 | ],
264 | "source": [
265 | "cz.utils.print_dataset(messageDataSet, name=\"Message Dataset\")"
266 | ]
267 | },
268 | {
269 | "cell_type": "markdown",
270 | "metadata": {},
271 | "source": [
272 | "# get all users"
273 | ]
274 | },
275 | {
276 | "cell_type": "code",
277 | "execution_count": 5,
278 | "metadata": {},
279 | "outputs": [
280 | {
281 | "name": "stdout",
282 | "output_type": "stream",
283 | "text": [
284 | "All Users : ['8d27cf2694', '78c4ca6671', '329233d117', '0041628436', 'bac412f897', '322692e582', 'e1ba3ba266', 'ae578bf678', '30b785e895'] \n",
285 | "\n"
286 | ]
287 | }
288 | ],
289 | "source": [
290 | "all_users = messageDataSet.get_all_users()\n",
291 | "print(\"All Users : %s \\n\" % all_users)"
292 | ]
293 | },
294 | {
295 | "cell_type": "code",
296 | "execution_count": 6,
297 | "metadata": {},
298 | "outputs": [],
299 | "source": [
300 | "search_user1 = \"0041628436\"\n",
301 | "search_user2 = \"329233d117\""
302 | ]
303 | },
304 | {
305 | "cell_type": "markdown",
306 | "metadata": {},
307 | "source": [
308 | "# get all connected users of a specific user"
309 | ]
310 | },
311 | {
312 | "cell_type": "code",
313 | "execution_count": 7,
314 | "metadata": {},
315 | "outputs": [
316 | {
317 | "name": "stdout",
318 | "output_type": "stream",
319 | "text": [
320 | "Users connected to 0041628436 : ['329233d117', 'bac412f897'] \n",
321 | "\n"
322 | ]
323 | }
324 | ],
325 | "source": [
326 | "connected_users = messageDataSet.get_connected_users(search_user1)\n",
327 | "print(\"Users connected to %s : %s \\n\" % (search_user1, connected_users))"
328 | ]
329 | },
330 | {
331 | "cell_type": "markdown",
332 | "metadata": {},
333 | "source": [
334 | "# get records between two selected users"
335 | ]
336 | },
337 | {
338 | "cell_type": "code",
339 | "execution_count": 8,
340 | "metadata": {},
341 | "outputs": [
342 | {
343 | "name": "stdout",
344 | "output_type": "stream",
345 | "text": [
346 | "{'_user': '329233d117', '_other_user': '0041628436', '_direction': 'Incoming', '_length': '7', '_timestamp': 'Mon Feb 11 07:08:49 +0000 1980'}\n",
347 | "{'_user': '329233d117', '_other_user': '0041628436', '_direction': 'Outgoing', '_length': '6', '_timestamp': 'Mon Feb 11 07:14:05 +0000 1980'}\n"
348 | ]
349 | }
350 | ],
351 | "source": [
352 | "user_record_list = messageDataSet.get_records(search_user1, search_user2)\n",
353 | "cz.utils.print_record_lists(user_record_list)"
354 | ]
355 | },
356 | {
357 | "cell_type": "code",
358 | "execution_count": 9,
359 | "metadata": {},
360 | "outputs": [
361 | {
362 | "name": "stdout",
363 | "output_type": "stream",
364 | "text": [
365 | "\n",
366 | " >>> User Records of 0041628436 & 329233d117 :\n",
367 | "+---+------------+-------------+------------+---------+--------------------------------+\n",
368 | "| | _user | _other_user | _direction | _length | _timestamp |\n",
369 | "+---+------------+-------------+------------+---------+--------------------------------+\n",
370 | "| 1 | 329233d117 | 0041628436 | Incoming | 7 | Mon Feb 11 07:08:49 +0000 1980 |\n",
371 | "| 2 | 329233d117 | 0041628436 | Outgoing | 6 | Mon Feb 11 07:14:05 +0000 1980 |\n",
372 | "+---+------------+-------------+------------+---------+--------------------------------+\n"
373 | ]
374 | }
375 | ],
376 | "source": [
377 | "user_message_dataset = cz.MessageDataSet(user_record_list)\n",
378 | "cz.utils.print_dataset(user_message_dataset, name=\"User Records of %s\" % search_user1 + \" & \" + search_user2)\n"
379 | ]
380 | },
381 | {
382 | "cell_type": "markdown",
383 | "metadata": {},
384 | "source": [
385 | "# visualize connections between all users"
386 | ]
387 | },
388 | {
389 | "cell_type": "code",
390 | "execution_count": 10,
391 | "metadata": {},
392 | "outputs": [
393 | {
394 | "name": "stdout",
395 | "output_type": "stream",
396 | "text": [
397 | "+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+\n",
398 | "| | 8d27cf2694 | 78c4ca6671 | 329233d117 | 0041628436 | bac412f897 | 322692e582 | e1ba3ba266 | ae578bf678 | 30b785e895 |\n",
399 | "+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+\n",
400 | "| 8d27cf2694 | . | 1 | . | . | . | . | . | . | . |\n",
401 | "| 78c4ca6671 | 1 | . | . | . | . | . | . | . | . |\n",
402 | "| 329233d117 | . | . | . | 2 | 4 | . | . | . | . |\n",
403 | "| 0041628436 | . | . | 2 | . | 4 | . | . | . | . |\n",
404 | "| bac412f897 | . | . | 4 | 4 | . | 33 | 1 | 1 | 3 |\n",
405 | "| 322692e582 | . | . | . | . | 33 | . | . | . | . |\n",
406 | "| e1ba3ba266 | . | . | . | . | 1 | . | . | . | . |\n",
407 | "| ae578bf678 | . | . | . | . | 1 | . | . | . | . |\n",
408 | "| 30b785e895 | . | . | . | . | 3 | . | . | . | . |\n",
409 | "+------------+------------+------------+------------+------------+------------+------------+------------+------------+------------+\n"
410 | ]
411 | },
412 | {
413 | "data": {
414 | "text/plain": [
415 | "([['8d27cf2694', '.', 1, '.', '.', '.', '.', '.', '.', '.'],\n",
416 | " ['78c4ca6671', 1, '.', '.', '.', '.', '.', '.', '.', '.'],\n",
417 | " ['329233d117', '.', '.', '.', 2, 4, '.', '.', '.', '.'],\n",
418 | " ['0041628436', '.', '.', 2, '.', 4, '.', '.', '.', '.'],\n",
419 | " ['bac412f897', '.', '.', 4, 4, '.', 33, 1, 1, 3],\n",
420 | " ['322692e582', '.', '.', '.', '.', 33, '.', '.', '.', '.'],\n",
421 | " ['e1ba3ba266', '.', '.', '.', '.', 1, '.', '.', '.', '.'],\n",
422 | " ['ae578bf678', '.', '.', '.', '.', 1, '.', '.', '.', '.'],\n",
423 | " ['30b785e895', '.', '.', '.', '.', 3, '.', '.', '.', '.']],\n",
424 | " ['',\n",
425 | " '8d27cf2694',\n",
426 | " '78c4ca6671',\n",
427 | " '329233d117',\n",
428 | " '0041628436',\n",
429 | " 'bac412f897',\n",
430 | " '322692e582',\n",
431 | " 'e1ba3ba266',\n",
432 | " 'ae578bf678',\n",
433 | " '30b785e895'])"
434 | ]
435 | },
436 | "execution_count": 10,
437 | "metadata": {},
438 | "output_type": "execute_result"
439 | }
440 | ],
441 | "source": [
442 | "messageDataSet.print_connection_matrix()"
443 | ]
444 | },
445 | {
446 | "cell_type": "code",
447 | "execution_count": null,
448 | "metadata": {},
449 | "outputs": [],
450 | "source": [
451 | "messageDataSet.visualize_connection_network()"
452 | ]
453 | },
454 | {
455 | "cell_type": "code",
456 | "execution_count": null,
457 | "metadata": {},
458 | "outputs": [],
459 | "source": []
460 | }
461 | ],
462 | "metadata": {
463 | "kernelspec": {
464 | "display_name": "Python 3",
465 | "language": "python",
466 | "name": "python3"
467 | },
468 | "language_info": {
469 | "codemirror_mode": {
470 | "name": "ipython",
471 | "version": 3
472 | },
473 | "file_extension": ".py",
474 | "mimetype": "text/x-python",
475 | "name": "python",
476 | "nbconvert_exporter": "python",
477 | "pygments_lexer": "ipython3",
478 | "version": "3.7.0"
479 | }
480 | },
481 | "nbformat": 4,
482 | "nbformat_minor": 4
483 | }
484 |
--------------------------------------------------------------------------------