├── README.md ├── logs ├── log1.txt ├── log2.txt └── log3.txt ├── merge.py ├── LICENSE └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # log-merge-tool 2 | Log file merge tool for CS 425 MP. 3 | -------------------------------------------------------------------------------- /logs/log1.txt: -------------------------------------------------------------------------------- 1 | 555,1,put,x,1522172706487,req,1 2 | 555,1,put,x,1522172707849,resp,1 3 | 555,1,get,x,1522172708852,req, 4 | 555,1,get,x,1522172710493,resp,1 5 | 555,1,put,x,1522172711495,req,2 6 | 555,1,put,x,1522172713041,resp,2 7 | 555,1,get,x,1522172714045,req, 8 | 555,1,get,x,1522172715213,resp,2 9 | 555,1,put,x,1522172716215,req,3 10 | 555,1,put,x,1522172717316,resp,3 11 | 555,1,get,x,1522172718320,req, 12 | 555,1,get,x,1522172719967,resp,3 13 | -------------------------------------------------------------------------------- /logs/log2.txt: -------------------------------------------------------------------------------- 1 | 555,2,put,x,1522172707093,req,1 2 | 555,2,put,x,1522172708453,resp,1 3 | 555,2,get,x,1522172709455,req, 4 | 555,2,get,x,1522172710678,resp,1 5 | 555,2,put,x,1522172711682,req,2 6 | 555,2,put,x,1522172713077,resp,2 7 | 555,2,get,x,1522172714082,req, 8 | 555,2,get,x,1522172715248,resp,2 9 | 555,2,put,x,1522172716252,req,3 10 | 555,2,put,x,1522172717351,resp,3 11 | 555,2,get,x,1522172718354,req, 12 | 555,2,get,x,1522172719707,resp,3 13 | -------------------------------------------------------------------------------- /logs/log3.txt: -------------------------------------------------------------------------------- 1 | 555,3,put,x,1522172707661,req,1 2 | 555,3,put,x,1522172709123,resp,1 3 | 555,3,get,x,1522172710128,req, 4 | 555,3,get,x,1522172711349,resp,1 5 | 555,3,put,x,1522172712352,req,2 6 | 555,3,put,x,1522172713748,resp,2 7 | 555,3,get,x,1522172714752,req, 8 | 555,3,get,x,1522172716146,resp,2 9 | 555,3,put,x,1522172717149,req,3 10 | 555,3,put,x,1522172718607,resp,3 11 | 555,3,get,x,1522172719612,req, 12 | 555,3,get,x,1522172721045,resp,3 13 | -------------------------------------------------------------------------------- /merge.py: -------------------------------------------------------------------------------- 1 | import csv 2 | from os import listdir 3 | from os.path import isfile, join 4 | 5 | path = './logs/' 6 | 7 | files = [f for f in listdir(path) if isfile(join(path, f))] 8 | 9 | data = [] 10 | 11 | for file in files: 12 | with open(path + file, newline='') as csvfile: 13 | reader = csv.reader(csvfile, delimiter=',') 14 | for row in reader: 15 | data.append(row[1:]) 16 | 17 | base = data[0][3] 18 | for row in data: 19 | row[3] = int(row[3]) - int(base) 20 | 21 | data = sorted(data, key=lambda row: row[3]) 22 | 23 | with open('line_log.csv', 'w', newline='') as csvfile: 24 | writer = csv.writer(csvfile, delimiter=',') 25 | writer.writerow(['Client', 'Request', 'Key', 'Timestamp', 'Action', 'Value']) 26 | for row in data: 27 | writer.writerow(row); 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Rijn Bian 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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | --------------------------------------------------------------------------------