Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hitfyd committed Jun 21, 2024
2 parents 2402fe6 + 4ab1384 commit dfa1ba5
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
18 changes: 18 additions & 0 deletions py/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# a simple python script to search keywords and display data
# able to run in Mac OS and linux

how to use
```
pip install -r requirements.txt
python query.py
```

dependancy (see [requirements.txt])
- pandas
- fuzzywuzzy
- simple-term-menu

screenshots

![](screenshot.png)

1 change: 1 addition & 0 deletions py/data
78 changes: 78 additions & 0 deletions py/query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""
# show JCR data with simple searching utility
TODO:
- add more data
- print complete list
"""

#config
data_folder="./data/"
data_file=data_folder+"JCR2022-UTF8.csv"


import csv
import pandas as pd
from fuzzywuzzy import fuzz
from fuzzywuzzy import process
from simple_term_menu import TerminalMenu


#load data into proper format, prepare menu
def init():
print("""
ShowJCR, Mar 28, 2024
""")
df=pd.read_csv(data_file)
col='IF(2022)'
df=df.replace({'<0.1':'0'}) # get data ready for float conversoin
df[col] = df[col].astype(float)
js=df['Journal'].tolist() #for fuzzy search
terminal_menu = TerminalMenu(
["[0] search", "[1] show full table", "[2] show table with IF>30"],
title="Show JCR menu. ENTER to select, q to quit"
)

return df,js,terminal_menu

import os
#print a page break
def page_break():
cols, lins = os.get_terminal_size()
print("~"*(cols-2))


def run(df,journal_list,terminal_menu):
menu_entry_indice = terminal_menu.show()
# menu_entry_indice = menu_entry_indices[0]
# print(menu_entry_indices)
print(menu_entry_indice)
if menu_entry_indice==1:
print(df)
elif menu_entry_indice==2:
d2=df.loc[ (df['IF(2022)'])>30]
print(d2)
elif menu_entry_indice==0:
journal=input('enter the journal name...')
print(journal)
r=process.extract(journal, journal_list, limit=6)
# print(r)
# for _ in r:
# print(_)
targets=[_[0] for _ in r ]
# page_break()
print(df.loc[ df['Journal'].isin( targets) ])
page_break()
else: #quit. also use escape or q to quit
return 0
return 1



def main():
df,journal_list,terminal_menu=init()
while(run(df,journal_list,terminal_menu)):
pass
print('Thanks for using the program. Goodbye!')

main()

11 changes: 11 additions & 0 deletions py/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fuzzywuzzy==0.18.0
Levenshtein==0.25.0
numpy==1.26.4
pandas==2.2.1
python-dateutil==2.9.0.post0
python-Levenshtein==0.25.0
pytz==2024.1
rapidfuzz==3.7.0
simple-term-menu==1.6.4
six==1.16.0
tzdata==2024.1
Binary file added py/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dfa1ba5

Please sign in to comment.