Skip to content

Instantly share code, notes, and snippets.

@canimus
Created January 7, 2021 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canimus/1292d6af370c6c65cf0f477165c12b1e to your computer and use it in GitHub Desktop.
Save canimus/1292d6af370c6c65cf0f477165c12b1e to your computer and use it in GitHub Desktop.
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