From a566821a8165ceb78d23450f9d42e9db25d44518 Mon Sep 17 00:00:00 2001 From: Graham Helton Date: Thu, 10 Mar 2022 12:27:37 -0500 Subject: [PATCH] Removed definition support having defintions was not very helpful when creating an index so I removed this feature --- README.md | 3 ++- index.py | 38 ++++++++++---------------------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 3e70bc8..31380a5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This is a program currently in development that I am creating to help make index Currently the indexer has the following features - Checks to see if you have any indexes in the current directory (Checks for .csv files) - If so it will ask you to select which index you would like to use, if not it will create a new one. -- Takes input in the format of **Term, definition, page number**. The three fields can be any an information you want in your index but it must be delimited by commas. +- Takes input in the format of **Term, page number**. The three fields can be any an information you want in your index but it must be delimited by commas. - You index is saved in the directory the program is launched from everytime you enter a new entry # This is still a work in progress. @@ -26,3 +26,4 @@ Currently the indexer has the following features - Add delete option for index files - ~~Add "ask for book" prompt on startup~~ - ~~Allow for input with no definition (term, pagenumber)~~ +- ~~Remove definition support (I found this was redundant and not helpful for an index)~~ diff --git a/index.py b/index.py index 45d44ba..187440f 100755 --- a/index.py +++ b/index.py @@ -6,7 +6,7 @@ import signal import pandas as pd from colorama import Fore, Style -headers = ['Title', 'Description','Page','book'] +headers = ['Title', 'Page','book'] index = [] row = [] dictionary = {} @@ -62,6 +62,7 @@ def init(): if x.endswith((".csv")): count+=1 dictionary[count]=x + print(sep) # For each key and value, in the dictionary, print key, value for user to select from for key, value in dictionary.items(): @@ -71,8 +72,9 @@ def init(): # Ask the user which file they would like selection = input(tick + green + " Type the number of the file you would like\n" + reset) + os.system("clear") - # If selecing existing csv, set csvName to choice and exit function + # If selecing existing csv, set csvName to choice and exit function if selection != "0": csvName = dictionary[int(selection)] print(tick, "You chose: ", csvName) @@ -92,12 +94,12 @@ def init(): return csvName def writeCsv(): + os.system("clear") with open(csvName, 'a') as f: write = csv.writer(f) write.writerows(index) def readIndex(csvName): - os.system("clear") print(tick, "Displaying entries for",cyan, csvName,reset) df = pd.read_csv(csvName) #bottom = df.tail() @@ -112,7 +114,7 @@ while True: index = [] row = [] # Get user input - newEntry = input(tick + green+" Enter your index entry. Format: Title, Description, Page\n" + reset) + newEntry = input(tick + green+" Enter your index entry. Format: Term,Page number\n" + reset) # Handle input if newEntry == "exit": writeCsv() @@ -123,9 +125,10 @@ while True: elif newEntry == "index": readIndex(csvName) - elif newEntry.count(',') != 2: - print(newEntry.count(',')) - print(tickBad + " Try again, make sure you have 2 commas") + elif newEntry.count(',') != 1: + print(newEntry.count(',')) + print(tickBad + " Try again, make sure you have 1 commas") + else: # Clear screen os.system("clear") @@ -142,24 +145,3 @@ while True: # Append row to list called index (This is a list of a lists) index.append(strippedRow) writeCsv() - - - - - - - - - - - - - - - - - - - - -