-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/hitfyd/ShowJCR
- Loading branch information
Showing
5 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../中科院分区表及JCR原始数据文件 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.