What to write or search on github to get the code for what is written below:

Avi Gross avigross at verizon.net
Sat Jan 22 16:27:11 EST 2022


I keep wondering about the questions asked by NArshad here. His message can be read below mine, for context.
This is a place focused on using the Python language. The web page being in HTML is beyond irrelevant and in particular, web pages generally are in HTML even if only as a way to call other functionality.
What I gather is that the web page, irrelevant if in HTML or JAVA or JavaScript or a connection with a server running python or anything else, asks the user to type in a book name to search for. NOTHING is of any importance here except capturing the exact text and sending it, or perhaps a lower case version, back to your server that does the search.
Does that make sense? If not, stop reading as nothing else will.
So, back on the server side, you get a single string of text that might look like "Great Expectations" and you want to find out if that matches a book title exactly or perhaps partially. Again, agreed?
So your program needs to have data available. What if the names of all the books were written in a regular text file one line at a time? Yes, they aren't but WHAT IF?
You would open the file and perhaps read a line at a time and compare the lower-case version of that line to a lower case version of the requested book name. An exact match could mean you close the file and return that you found it, however that is done. No match means read the next line and repeat. If you get to the end of the file without finding it, you failed and close the file and return that result.
Of course some might do a bit more than convert to lower case such as removing multiple white space in both things being compared, or dropping other parts like commas of quotes as in changing "Mine,      didn't I    say!" to "mine didnt i say" so more things match as intended. Plenty you can do if you wish. Python has plenty of ways to do all that and more.
Now forget the plain text file and consider the following. Read the EXCEL file one unit/cell at a time in whatever column and row the data starts. This is doable, albeit not necessarily ideal and basically can be the same algorithm with a substitution in the part that gets the next line to getting the cell below it. Testing for end of file may be different too.
But what I think makes a bit more sense is to setup the server to have a rather long-term process that sits there and waits for requests. It starts by reading in ALL the data and perhaps modifying it once in ways like I suggest above. In python you would now have some data structure such as a list or set or even dictionary or some variation from numpy or pandas. It does not matter much. The data structure holding all books, or maybe all unique book names, would be there and ready and waiting.
Your program now sleeps until woken up and it is given the book name being searched for. It now simply needs to apply whatever transformations you want to the received name and then do one of many kinds of lookup to see if it is in the data structure representing the titles known to the library. Using a set or dictionary means no search as it hashes the result and rapidly finds out if it has previously been stored. Other methods like lists have choices between a brute force linear search if the data remains in the original order or letting python do the work by asking if it is "in" the list to more sophisticated methods like keeping it sorted and doing a binary search.
I am guessing that for your need, a relatively unsophisticated method may work fine and it can be changed if your project scales up to millions of books and multiple people searching at the same time.
And note you are now asking about a very limited thing. As others have pointed out, there can be much more complex requests such as checking if a copy of the book is free, and reserving it so others requesting it see as checked out and logging it back in again and more. And obviously more work is needed if you want to support more of a google-style search engine that matches books that contain only parts of your request.
But note what I am describing can be done by pretty much ANY language as long as it can open and read your data storage format. HTML all by itself can display a form with a text box and some kind of SUBMIT button and when you click on it call a CGI on a server and display what it returns. For the simple scenario you mention, you do not need openpyxl. But my guess is you are making something with additional functionality based on earlier posts and thus need to take care that anything you do can be extended to add functionally, so a raw HTML solution may not easily meet other needs. 
I keep hearing you searching for a solution and you may find one but mostly you need to design your own solution that meets your needs and use the search more for small pieces of the design like "how to efficiently search using a set in python" ...
As has been said repeatedly, if you really need the result soon and really are not yet up to the job or have time to learn, then either tell them you can't do it or get someone hired. But note, in the latter case you need to stop wasting time and tell them in great detail what you want done and let them see the data and so on. Otherwise, you may pay for lots of hours or have people walk away.
AGross

-----Original Message-----
From: NArshad <narshad.380 at gmail.com>
To: python-list at python.org
Sent: Sat, Jan 22, 2022 5:22 am
Subject: Re: What to write or search on github to get the code for what is written below:


The user is going to enter the book name as the input of an HTML form on a website and I have to check whether the book is present or not in the Excel table. openpyxl preferred pandas is also fine anything left. Case sensitivity is not required. I tried to find code or tutorial on google search for all this but no use that's why..................

This time the choice of HTML is right or not??
-- 
https://mail.python.org/mailman/listinfo/python-list


More information about the Python-list mailing list