Skip to content

Instantly share code, notes, and snippets.

@canimus

canimus/parser.py

Created Jan 7, 2021
Embed
What would you like to do?
termgraph test cases
#!/home/herminio/py385/bin/python
import glob
import json
import chalk
import asyncio
import aiofiles
import tabulate
import pandas as pd
import itertools as it
async def read_tags(f):
async with aiofiles.open(f, mode='r') as reader:
content = json.loads(await reader.read())['labels']
return [x for x in map(lambda x: x['value'], content)]
files = glob.glob('./*.json')
tags = []
for file in files:
tags.append(asyncio.run(read_tags(file)))
tag_set = set(it.chain.from_iterable(tags))
df = pd.Series([*tag_set]).rename('tags').to_frame()
print(df.tags.str.split(":").apply(pd.Series).rename(columns={0:'tag', 1:'case'}).case.str.split("-").apply(pd.Series)[0].value_counts())
# run script
# ./parser.py | grep -v ":" | termgraph --color black
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment