Mailing List Archive

1 2 3  View All
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On 14/01/2022 09.48, Dennis Lee Bieber wrote:
> On Thu, 13 Jan 2022 15:22:50 -0500, Dennis Lee Bieber
> <wlfraed@ix.netcom.com> declaimed the following:
>
> Talking to myself in public again... Bad habit...

Recommend that you not start any arguments then
- they will be unwinnable!

--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On 14/01/22 12:23 pm, dn wrote:
> On 14/01/2022 09.48, Dennis Lee Bieber wrote:
>> On Thu, 13 Jan 2022 15:22:50 -0500, Dennis Lee Bieber
>> <wlfraed@ix.netcom.com> declaimed the following:
>>
>> Talking to myself in public again... Bad habit...
>
> Recommend that you not start any arguments then
> - they will be unwinnable!

But at least they'll be free of charge!

--
Greg

--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On Thu, 13 Jan 2022 23:08:19 +0000 (UTC), Avi Gross <avigross@verizon.net>
declaimed the following:

>So the suggestions to copy the data ONCE into something else (a CSV, database, whatever) that can be used externally are reasonable but seem to be resisted. I would guess some of the "missing" functionality others wonder about such as making reports, may still be available within other sheets or parts of the EXCEL .xlsx or other format file.

Ignoring the data store itself, the OP has also stated (if poorly) that
this application is supposed to be hosted on Heroku (I suspect this is an
assumption they made, as that minimal "Hello World" Flask tutorial they are
using gives instructions for a limited free/hobbyist Heroku instance). If
this application is really for some client (the book repository staff) one
would think they'd have specified the web hosting system in advance.

That (web hosting) compounds the problem of the lack of reporting...
The defined application is essentially "write-only" -- in that the only
operation available is to reserve/check-out book(s) based upon availability
count. There is no means provided by which these reservations are passed on
to whoever is responsible for physically handing out books, nor to track
who has received their copy. Are any/all "repository" employees supposed to
access the spreadsheet? How? Do they all have the account/password to the
Heroku (or other web hosting service) in order to FTP the data down for
local usage (how many such copies will there be, and how are they
synchronized).

Or is the CONOPS that only the repository employees access the
application, on behalf of the person making the reservation/check-out
request -- and hence the application is merely recording information of who
has physically received a book (in which case the overhead of tracking
availability seems superfluous, as the staff would see that the table(s) of
books does not have the title, so it is unavailable for handing over).



--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
What Dennis Lee is saying I will see to it later.

Right now what mrabarrnett is saying is of use.



Why does the code written below is not giving any output?

xls = ExcelFile('ABC.xlsx')
df = xls.parse(xls.sheet_names[0], index_col=1)
x=df.to_dict()
print (x)

Only the contents of the first column and the column number is required in the dictionary
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On 1/13/22 16:08, Avi Gross via Python-list wrote:
>
> I am not replying to anything below so I have removed it.

> Instead, someone suggested Python which indeed, with lots of work, can open just about ANY nonsensical file and diddle around and rewrite it, but WHY?

well, the topic *was* raised on a PYTHON list...


--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
Mats,
Yes, this is a Python mailing list and I welcome people interested in doing something in Python who need a little help or advice but have some idea of what they are doing and present us with enough info more than "something does not work."

Yes, the topic was raised on a Python list but I did not get the impression the person asking necessarily knew a lot about Python or maybe other languages. I may well be wrong. They seem to have been handed something to work on and maybe are searching for some way to do it. You can do what was asked in plenty of languages, some easier and some harder. But some are better set to do things in a browser/server model than others.
One impression is they were suggested to use a web platform of sorts and from there went to Python as compatible for the server side. But the overall tone suggests to me that they want to be given a quick solution for a problem they do not really understand, let alone the tools they want to use. And I do not perceive much willingness to take the time to do much learning. My willingness to help and my time to do so, are limited and I said so. Others, feel free. The reality is many here want to be hired for large and complex jobs.
If someone had suggested to them to use JavaScript written inside a web page to read the file and do searches, and forgot to tell them that writing the file back onto some server might not be trivial, I wonder if they would have gone in another direction.
Again, these are my impressions and why I wondered if there was a GOOD reason they asked about Python. My experience in the past includes seeing posts by people who sent messages to multiple groups I was on for multiple languages and asked how to do something. They just were hoping someone would post complete code and they could then move on without learning anything. Maybe I am a tad jaundiced and prefer honest requests from people willing to listen to what feedback we provide and show some code for us to look at and perhaps help improve.

-----Original Message-----
From: Mats Wichmann <mats@wichmann.us>
To: python-list@python.org
Sent: Sat, Jan 15, 2022 3:05 pm
Subject: Re: What to write or search on github to get the code for what is written below:

On 1/13/22 16:08, Avi Gross via Python-list wrote:
>
> I am not replying to anything below so I have removed it.

> Instead, someone suggested Python which indeed, with lots of work, can open just about ANY nonsensical file and diddle around and rewrite it, but WHY?

well, the topic *was* raised on a PYTHON list...


--
https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On 15Jan2022 02:38, NArshad <narshad.380@gmail.com> wrote:
>Why does the code written below is not giving any output?
>
> xls = ExcelFile('ABC.xlsx')
> df = xls.parse(xls.sheet_names[0], index_col=1)
> x=df.to_dict()
> print (x)
>
>Only the contents of the first column and the column number is required
>in the dictionary

The code above _must_ produce some output, even if it is very short, or
an error traceback. Is "x" an empty dictionary? Are you getting an
exception? What is in ABC.xlsx, at least in part? What modules are you
importing in order to get the name "ExcelFile"? I'm guessing pandas, but
that is from a web search.

Cheers,
Cameron Simpson <cs@cskk.id.au>
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On 1/15/22 14:24, Avi Gross via Python-list wrote:
> Mats,
> Yes, this is a Python mailing list and I welcome people interested in doing something in Python who need a little help or advice but have some idea of what they are doing and present us with enough info more than "something does not work."
>
> Yes, the topic was raised on a Python list but I did not get the impression the person asking necessarily knew a lot about Python or maybe other languages. I may well be wrong. They seem to have been handed something to work on and maybe are searching for some way to do it. You can do what was asked in plenty of languages, some easier and some harder. But some are better set to do things in a browser/server model than others.

I only meant, in response to "someone suggested" in the quoted snip
below, since it was asked here, someone suggesting Python was a pretty
expected outcome...


> -----Original Message-----
> From: Mats Wichmann <mats@wichmann.us>
> To: python-list@python.org
> Sent: Sat, Jan 15, 2022 3:05 pm
> Subject: Re: What to write or search on github to get the code for what is written below:
>
> On 1/13/22 16:08, Avi Gross via Python-list wrote:
>>
>> I am not replying to anything below so I have removed it.
>
>> Instead, someone suggested Python which indeed, with lots of work, can open just about ANY nonsensical file and diddle around and rewrite it, but WHY?
>
> well, the topic *was* raised on a PYTHON list...
>
>

--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On Sat, 15 Jan 2022 02:38:34 -0800 (PST), NArshad <narshad.380@gmail.com>
declaimed the following:

A bit of an improvement -- actual code...

But... still not a minimal /runnable/ example...
>
>Why does the code written below is not giving any output?
>
> xls = ExcelFile('ABC.xlsx')

Where is "ExcelFile" defined? Best match I could find after spending
time with Google is the pandas package. Pandas is likely overkill for this
situation -- being optimized for analysis of numerical tabular data. In
particular, it expects each column to be of one data type, not mixed data
types, in order to apply aggregate functions (min, max, mean, std.dev.,
etc.) to the columns.

> df = xls.parse(xls.sheet_names[0], index_col=1)

Based upon documentation, pandas.ExcelFile.parse() internally uses the
openpyxl package for files of type .xlsx -- for this application openpyxl
is probably all that is needed.

Documentation for .parse() (actually the underlying .read_excel()
operation) indicates that the desired sheet can be specified by name OR BY
POSITION -- with the default value being "0" [first sheet]. It is somewhat
perverse to be retrieving a list sheet names from the file, only to then
pass the first name back into the function which has to match the name up
against the list to determine the position... Unless the file is using
multiple sheets for data -- in which case you need some logic to select
something other than the first sheet -- you could leave that argument off
and let it default.

index_col=1 says to use the SECOND COLUMN of the sheet to provide
row-labels for the "dataframe" (unless documentation states otherwise, the
first item of a collection is "0", not "1")

> x=df.to_dict()

What do you really expect from this conversion? With no arguments it
will produce a nested dictionary of the form

{ "column1name" : { "row1name" : r1-c1-value ,
"row2name" : r2-c1-value },
"column2name" : { "row1name" : r1-c2-value,
"row2name" : r2-c2-value } }

> print (x)
>
>Only the contents of the first column and the column number is required in the dictionary

You won't get that with .to_dict() -- it uses the column names for the
major grouping, and then uses the row names (which are already garbage as
you told pandas to use the second column for row names) to select the VALUE
stored in that row for that column. Also, while Python implementation of
dictionaries has changed over the years, the theoretical basis (associative
mapping, hash table) does not define an order for the keys of the
dictionary. Unless you are certain of how a dictionary handles
insert/delete of keys, you can not assume the first key out was the first
key that went in.

It would also be helpful to have a snippet of the spreadsheet -- say
the first five or six rows, along with the first five or six columns;
exported as a CSV file (binary attachments get stripped from this forum,
but a CSV is text and can be pasted in -- 5x5 should be small enough that
those trying to assist can then extract it from the post, clean up any line
wrappings, and import into a blank spreadsheet.


--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
Avi Gross:

-“They just were hoping someone would post complete code and they could then move on without learning anything.”

This is due to the time factor
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On Tue, Jan 18, 2022 at 2:46 AM NArshad <narshad.380@gmail.com> wrote:
>
> Avi Gross:
>
> -“They just were hoping someone would post complete code and they could then move on without learning anything.”
>
> This is due to the time factor

Then pay someone to write it. There are plenty of contractors out
there. You can't expect this list to be a free consulting programmer
for you.

I strongly encourage everyone to stop helping the OP until there's
some code to help with.

(I'm not surprised, given that the original request was basically
"what should I search for to magically find what I want".)

ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On Tue, 18 Jan 2022 02:51:22 +1100, Chris Angelico <rosuav@gmail.com>
declaimed the following:

>
>I strongly encourage everyone to stop helping the OP until there's
>some code to help with.
>
Well, we did squeeze about four lines of code from the OP -- though
still incomplete (no import statements so we have to research what 3rd
party module the OP might be invoking -- and they seem to have totally
skipped direct usage of an module for reading Excel format files in favor
of loading the massive pandas package [.with its need for those direct
reading modules along with SciPy/NumPy -- does it also load matplotlib?]).

>(I'm not surprised, given that the original request was basically
>"what should I search for to magically find what I want".)

To which the closest viable response I've extracted is to Google

python library management system

(presuming Python is a firm requirement). Of course all of those have the
problems

1A They use an RDBM (most examples seem to be MySQL based,
though SQLite3 might show up in some)
1B No sign of Excel spreadsheets anywhere

2A They handle adding/removing books from the inventory
(permanent actions), along with
2B Check-out/Check-in of books from the inventory (OP seems to
only focus on Check-out/Reservation)
2C They may even track who is allowed to run the application
(staff only... for all functions or just some, etc.)

3 Every copy of a book is an individual record in the
database -- if there are 30 copies of a book, there are 30 records for it,
and each copy can only have one check-out at a time; no "decrement" of a
"number available".

4 Some are local/desktop applications using Qt or similar GUI
framework, others might be web-based but likely not Flask


{And, from my personal viewpoint, they may be using SQLAlchemy... I
have the O'Reilly text for that, and find it still makes no sense to me...
I can code direct SQL queries faster than trying to figure out the
equivalent functionality in SQLAlchemy... And if the OP has a fixation on
spreadsheet views of the data, SQLAlchemy will really be a mystery.

}


--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
I can appreciate people under time pressure wanting the job DONE first and maybe learning more after. So, yes, it makes perfect sense to delegate the task to others with expertise or ask for advice.
This forum may mean many things to many people but for me, it is a place to offer guidance and small amounts of help as a voluntary activity. Doing a major project for free is not necessarily why I am here. I prefer being hired and compensated, LOL!
But I share the frustration when someone dumps an ill-defined project on you without realizing what they handed you is an old application that cannot trivially be shifted into something new without serious effort and preparation.
The feedback here has included suggestions that we were shown only a part of the task needed and that it would be a good idea to not even try to keep your data in some EXCEL format if it was used heavily in ways perhaps never intended. Obviously, feeling urgency to do something quickly will make it hard to accept our suggestions, but nonetheless, a request here, as has been pointed out, should anticipate a python-oriented answer. Asking us here to make a set of macros for EXCEL to do this task would be inappropriate. Some are suggesting that a solution that keeps reading and writing to an EXCEL file for each transaction is also not necessarily a great design.
I think your answer makes me amend what I wrote. I grant you may be interested in learning but due to the press of time, you want a working set of software first.
Good luck with that. 

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

Avi Gross:

-“They just were hoping someone would post complete code and they could then move on without learning anything.”

This is due to the time factor
--
https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On Mon, 17 Jan 2022 01:55:15 -0800 (PST), NArshad <narshad.380@gmail.com>
declaimed the following:


>This is due to the time factor

And that opens another can of worms... Before this "assignment" was
given to you, surely someone made some sort of estimate of how long it
would take to produce, taking into account your (apparent) lack of
familiarity with any of the technology required.

Python, Flask, and web-hosting (on Heroku) all appear to be a result of
stumbling onto a "Hello World" tutorial that does no persist ant data
storage and relies upon a free/hobbyist level account on the hosting
provider -- an obvious flag that this is not a well thought out project for
some actual customer/employer (it might qualify as an internship assignment
at some school looking to automate the reservation/check-out of text
books). The lack of understanding in how Python dictionaries are
manipulated doesn't leave one impressed either...

In one respect, given the limited functionality stated, one gets the
impression of a class GROUP assignment, in which the individual functions
were divvied up to each group member to work, with pretty much no analysis
of suitable data storage, etc. (You only gave some sort of CONOPS for
"users" to "reserve" books; no CONOPS for unreserving books, an implication
that after reserving books the user will go to some desk [.in library, in
store {unlikely if there is a return date for books}, some warehouse] and
receive a copy of the reserved book -- but no CONOPS for how this deck
validates that the user has reserved any particular book [.no report printed
by user of reservations made during a session, no search function for desk
staff, etc.).

The Excel requirement comes across as "this is how we've been doing it,
and we have a lot of data in the file we don't want to lose". In other
words -- one should have defined a migration path to replace the Excel
spreadsheet with something suited to a multi-user and/or web-based
application. That, or someone in the group has squashed any discussion on
data storage to force their biased viewpoint. (I've been on the fringe of
one such: in a department with over 80 VAX FORTRAN-77 programmers [.some of
us quite skilled in working the internals of the language] and some 20-30
PDP Macro-11 programmers, the Macro-11 group was tasked with porting their
application to VAX systems. One person held out for the port to be done in
VAX Pascal "because colleges were teaching Pascal" at the time [TurboPascal
in all likelihood] totally ignoring the massive F-77 expertise available;
he also is rumored to have threatened to leave if Pascal was not chosen and
management caved-in. Even though VAX Pascal was much different from
TurboPascal [.no development environment, though it did support separate
compilation and linking], it did not have advanced math
operations/functions -- just the ones found in Jensen&Wirth, try doing
orbital computations with a subset of trig functions -- requiring
programmers to import the F-77 runtime library for the missing functions. A
few years later the manager confessed that submitting to Pascal was a
mistake -- it didn't take long for the VAX Pascal project to be ported to
HPUX workstations using C and X-window system).


I also note that during the course of this thread, the spreadsheet
appears to have gone from a somewhat logical "one-row per title"

TITLE | AUTHORs | INVENTORY | AVAILABLE ...
A Book Someguy 10 9 ..
Book 2 Who Dat 100 100 ...
Popular Madonna 30 1 ...

to the illogical "one-column per title"

TITLE A Book Book 2 Popular
AUTHORs Someguy Who Dat Madonna
INVENTORY 10 100 30
AVAILABLE 9 100 1
...

Consider that Excel only supports some 16K columns, but 1M rows, and
expanding each column to show, say a 200 character title (there are some
long book titles in the world) results in only two or three books being
visible at a time... And there is no "side scroll" page key. In contrast
the first layout would only need one column to be expanded, the rest can be
narrower, and one can use page-up/page-down to scroll through a lot of
books at a time. Oh, and while a cell can hold some 4K text -- Excel itself
can only display the first 255 of those. That's going to put a limit on how
many names you can fit in the reserved-by column (about 10 25char names)
and easily find while scrolling. More than that and you have use "Find"
operations from the menu.

Heroku-Specific note: a recent web-page I encountered searching for
information for a different question indicates that Heroku does not support
SQLite3 and, by extension, ANY file-based dynamic data storage (so, no
Excel files either). An Heroku Python "dyno" [virtualized work container]
is initialized using a requirements file -- that file basically lists all
the 3rd party Python modules that need to be installed using "pip". If the
"dyno" is stopped (application shut down to upload modifications, or maybe
just to remove an application that has been idle for some hours) it, and
any data files, are just deleted -- when someone tries to connect to the
app again, a new "dyno" is spun up and loaded from scratch. One is supposed
to use one of the client server databases provided by Heroku for persist
ant storage (since those are not inside "dyno" container -- the app makes a
network connection to the database server.


--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On Tue, Jan 18, 2022 at 7:44 AM Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
> Heroku-Specific note: a recent web-page I encountered searching for
> information for a different question indicates that Heroku does not support
> SQLite3 and, by extension, ANY file-based dynamic data storage (so, no
> Excel files either). An Heroku Python "dyno" [virtualized work container]
> is initialized using a requirements file -- that file basically lists all
> the 3rd party Python modules that need to be installed using "pip". If the
> "dyno" is stopped (application shut down to upload modifications, or maybe
> just to remove an application that has been idle for some hours) it, and
> any data files, are just deleted -- when someone tries to connect to the
> app again, a new "dyno" is spun up and loaded from scratch. One is supposed
> to use one of the client server databases provided by Heroku for persist
> ant storage (since those are not inside "dyno" container -- the app makes a
> network connection to the database server.

This is correct. I've used Heroku for a number of projects, since it's
easy to deploy there and can be done for zero dollars. If you know how
to use PostgreSQL from Python, it's almost trivially easy to deploy
that to Heroku (just need to arrange your credentials, nothing more).
In contrast, manipulating external files is tricky; in fact, if you
want to do something simple like "upload an image to use as your
avatar", it's probably easier to store that in Postrges than on the
file system.

Part of the reason for the "wipe everything on shutdown" policy is
that it makes Heroku apps extremely easy to scale. You want one
process? Done. Want two dynos so you can serve more clients at once?
Easy. But for that to work, you have to make absolutely sure that
everything is stored externally to the dyno itself.

Like everything else, it requires discipline, a set of rules that you
follow. (And it's a lot easier than some - for instance, the
discipline required for a live-code-update system is a lot harder.)
But while it isn't particularly difficult, it does require some
comprehension. Some time investment. Some actual effort. And that's
what the OP might be running into difficulties.

(For what it's worth, we used Heroku at my last teaching job; it's a
great way to ensure that every student is able to deploy projects, and
since it doesn't cost anything to have a bunch of projects up there,
it doesn't hurt to deploy apps that don't have any "real-world use".
Originally we taught them to use MongoDB, which requires external
hosting, but switched that out for PostgreSQL, which is ever so much
better to work with.)

ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
Avi Gross:

What does the website "https://mail.python.org/mailman/listinfo/python-list" do?

Can I use this for the discussions which I require?
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On Tue, 18 Jan 2022 07:37:07 -0800 (PST), NArshad <narshad.380@gmail.com>
declaimed the following:

>Avi Gross:
>

Not Avi Gross, but that is partly because you replied to Chris
Angelico, who was replying to my post replying to an earlier one of
yours...

>What does the website "https://mail.python.org/mailman/listinfo/python-list" do?
>
>Can I use this for the discussions which I require?

It is most likely the same forum...

The Python mailing list (which does get spam filtered, unlike the
Usenet newsgroup, so doesn't see as much junk injected via Google) is
gatewayed with Usenet comp.lang.python. comp.lang.python is what Google
gateways for its Python group. Anything posted on the Google Python group
is seen by comp.lang.python, and from there gets seen by the Python mailing
list (and things go the other way also). The only difference is message
management -- email vs news reader vs whatever Google's interface of the
week inflicts, and how much spam comes through. For me, mailing lists take
too much management to set up filters to file mailing list traffic to a
special mail box (and then if I need other filters, to ensure they apply
before or after the mail box filing) whereas a decent news reader
automatically files messages by their group.









And you really need to find a client that follows (or properly use the
one you have) email/netnews /threading/ and attribution conventions. Avi
Gross's post was on a different path (there was a three-way split from your
earlier post).

If you are going to be explicitly asking questions of a person, that
post should be a follow-up (reply) to the nearest relevant post made by
that person -- not just tacked onto the end of the posts that came in
during the day with all content removed and ad hoc comments inserted.



--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
o/~ talking to myself in public o/~

On Mon, 17 Jan 2022 15:39:25 -0500, Dennis Lee Bieber
<wlfraed@ix.netcom.com> declaimed the following:


> In one respect, given the limited functionality stated, one gets the
>impression of a class GROUP assignment, in which the individual functions
>were divvied up to each group member to work, with pretty much no analysis
>of suitable data storage, etc. (You only gave some sort of CONOPS for
>"users" to "reserve" books; no CONOPS for unreserving books, an implication
>that after reserving books the user will go to some desk [.in library, in
>store {unlikely if there is a return date for books}, some warehouse] and
>receive a copy of the reserved book -- but no CONOPS for how this deck
>validates that the user has reserved any particular book [.no report printed
>by user of reservations made during a session, no search function for desk
>staff, etc.).

I'm in a fey mood today... The OP (and the rest of you reading) will
likely just skip this message... It's a rambling free-association harangue
on a possible RDBM schema -- which makes a few assumptions (described
following) and looks wildly different from the OP's vague data...

Inferred from various posts is that this
* NOT a library (which may have at most 5 copies of popular
books)
* NOT a book store (which would not have check-out/check-in
dates)

The best use case I can see is for something like a high school in
which textbooks are issued to students at the start of the course, and
collected at the end. For a small high school, say 600 students, there
might be 150 taking, say 3rd year Trigonometry, split among 6 session of 25
students each day. This justifies not tracking every copy of a book by full
title, et al.

I'm going to take that as the overall system CONOPS.

Needed data: book title, book author(s), ISBN and/or other call number
(some texts may be old enough to predate ISBN), # copies, # available,
dates for check-out and return, student name. Probably more as I go down...

Schema format notation:

relation(attribute list)
special constraints description

where
*attribute* is a non-null, unique index, primary key (preferably
autonumber)
_attribute_ is a non-null, duplicates allowed index, foreign key (in
the form relation-attribute)
/attribute/ is an optional/alternate indexed attribute

Publisher(*ID*, name)

Book(*ID*, ISBN, alt-call, title, _Publisher-ID_, copyright-date)
constraint(ISBN not null OR alt-call not null)

Author(*ID*, /last-name/, first-name)
constraint(last-name not null)

Book-Author(*ID*, _Book-ID_, _Author-ID_)
{this links authors to books, and allows for books to have more than
one author}

Copy(*ID*, _Book-ID_, copy-number, status, condition)
constraint(status in "A", "O", "R", status not null, default "A")
constraint(copy-number not null, [Book-ID copy-number] is unique)
{A = available, O = checked out, R = reserved but not yet checked
out}
{condition contains notes on known damage, etc. for this copy}

Student(*ID*, /last-name/, first-name)
constraint(last-name not null)
{I expect this to expand with student ID number, home address,
etc.)

CheckOut(*ID*, _Copy-ID_, _Student-ID_, reservation-date, checkout-date,
due-date, active)
constraint([Copy-ID Student-ID] is unique)
constraint(active not null boolean default true)
{can automate cancelling reservations after n-days, and can also be
used to produce a list of past-due}
{active is used to allow for history of check outs, set to false
when book is returned (and hence made Available again)

SEVEN relations (aka "tables") in an RDBM. While each book /title/
appears only once, it does take a small record to identify each copy of the
book and track availability of the copy. Reserving a book requires
transaction to select the first copy with status = "A" for that title,
update status to "R", insert a checkout record with the currently selected
student and current date for reservation date. When actually given the
book, a transaction to find the active checkout record for the student, for
that title is done, the checkout and due dates are set, the copy record is
updated for status = "O". When returned, a transaction is done to locate
the checkout record, update active to false, update Copy record to set
status to "A", and optionally update the condition field to indicate
damages inflicted by the student while it was checked out. If a reserve
operation fails (another session snagged the same copy record and updated
it) one just repeats the transaction trying for the next available copy
record -- only if there are no copies with status "A" do you have to abort
and tell the student they can't have the book.

There is no "count" of copies, no "count" of available -- these can be
computed based upon SQL cnt() functions; untested

select b.title as Title,
cnt(cpy1.copy_number) as Total,
cnt(cpy2.copy_number) as Available
from Book as b
inner join Copy as cpy1
on b.ID = cpy1.Book-ID
left join Copy as cpy2
on cpy1.ID = cpy2.ID and cpy2.status = "A"
group by b.title
order by b.title;


--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
I do not manage any python lists or have any say in how they run so I have no idea why I am being asked by name below, as Dennis pointed out.
So I won't reply on whatever I am being asked, but want to point out that many forums may be asked questions and some people on the forum will not respond or will not accept a user that bombards with too many questions or requests for more detailed answers and especially when not given enough but appropriate information.
Not everything in life is free. Python as a free language is but the expertise in ways to solve specific problems using Python, let alone EXCEL, that you want, often is not.
Simple requests like how to read in data from a format like .CSV or a tab in .XLSX files can be easily answered, of course. But correcting what sounds like a horrible data storage without a redesign is often not of much interest to others.
I think this group has already spent way too much time on whatever this issue is and provided lots of useful advice which apparently does not get taken. So don't pull me in again. I have moved on.


-----Original Message-----
From: Dennis Lee Bieber <wlfraed@ix.netcom.com>
To: python-list@python.org
Sent: Tue, Jan 18, 2022 2:44 pm
Subject: Re: What to write or search on github to get the code for what is written below:

On Tue, 18 Jan 2022 07:37:07 -0800 (PST), NArshad <narshad.380@gmail.com>
declaimed the following:

>Avi Gross:
>

    Not Avi Gross, but that is partly because you replied to Chris
Angelico, who was replying to my post replying to an earlier one of
yours...

>What does the website "https://mail.python.org/mailman/listinfo/python-list" do?
>
>Can I use this for the discussions which I require?

    It is most likely the same forum...

    The Python mailing list (which does get spam filtered, unlike the
Usenet newsgroup, so doesn't see as much junk injected via Google) is
gatewayed with Usenet comp.lang.python. comp.lang.python is what Google
gateways for its Python group. Anything posted on the Google Python group
is seen by comp.lang.python, and from there gets seen by the Python mailing
list (and things go the other way also). The only difference is message
management -- email vs news reader vs whatever Google's interface of the
week inflicts, and how much spam comes through. For me, mailing lists take
too much management to set up filters to file mailing list traffic to a
special mail box (and then if I need other filters, to ensure they apply
before or after the mail box filing) whereas a decent news reader
automatically files messages by their group.









    And you really need to find a client that follows (or properly use the
one you have) email/netnews /threading/ and attribution conventions. Avi
Gross's post was on a different path (there was a three-way split from your
earlier post).

    If you are going to be explicitly asking questions of a person, that
post should be a follow-up (reply) to the nearest relevant post made by
that person -- not just tacked onto the end of the posts that came in
during the day with all content removed and ad hoc comments inserted.



--
    Wulfraed                Dennis Lee Bieber        AF6VN
    wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
--
https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
- I will try to follow all that you people are saying, but it will take time or next time. The chance of concurrency is very less. Kindly don't write big descriptions.

- The weblink Avi Gross has given is very useful.






--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
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
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On Sat, 22 Jan 2022 02:22:14 -0800 (PST), NArshad <narshad.380@gmail.com>
declaimed the following:

>
>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??

HTML is the core basis for any web-site presentation -- no HTML, no
web-page.

Interaction with a displayed web-page is via... CGI (individual scripts
that process returned data -- somewhat slow as originally each invocation
requires a full server process startup and shutdown; advances were made to
try to keep a single process running for multiple invocations), AJAX
(Javascript running in the browser making internet requests and modifying
the "document object model" [DOM] in the browser to update the page without
hitting the server for a full update transfer).

Flask, Django, and some others are packages to consolidate what had
been static pages and CGI into a framework that handles an entire "site" --
via templates for look&feel, session management (and cookies) so that
interaction can be tracked to users (HTTP is a fire&forget system -- every
URL sent to the server is treated as a completely separate request).

Above those frameworks are things like Zope -- so-called content
management frameworks.


And again... You will not find anything like you want... NOBODY is
going to write a web application using a spreadsheet as the primary data
storage. A spreadsheet, and custom transformation code, MIGHT be used to
initially populate a database. (M$ SQL Server Integration Services is a
whole system for defining import/transformation/clean-up "functions" for
data sources to data base). A spreadsheet might be available as a
report/extraction format from the database.

Using a web server means you have to be able to handle (near)
simultaneous requests from multiple users and be able to keep those
interactions distinct. That is going to require you to implement some sort
of access control for a spreadsheet, since spreadsheets are single-user
entities (you might get away with shared reading as long as you never need
to update any field in the spreadsheet; as soon as you need to update, you
need to be able to lock records so only one session can update it, and you
need to have a way for other sessions to detect such changes and update
that sessions display for review). On possibility might be to write a
separate process wherein only that process opens the spreadsheet -- all the
web-page stuff will have to generate complete I/O requests to the
spreadsheet process, it will make the changes, and return whatever data is
applicable ("complete" meaning that, if you need to change three fields in
a record, all three commands are provided as ONE request to the spreadsheet
process, and it does all the changes in the request before it goes on to
read the next request). This still falls short of detecting overlapping
changes -- two users want to do something with the same record; they each
read the record, then send commands to change the same field. Which ever
one is received first should complete, and the other needs to be rejected
and resubmitted.



Show us code you've written, and we can assist in debugging it. But you
couldn't afford to have any of us write the application for you! (To cover
insurance, taxes, etc. an independent contractor would probably charge you
$100+ an HOUR -- and the first hours look like they'd be spent getting
detailed requirements from you, discussing design problems [spreadsheet as
data storage], before even getting to any coding. That's real-world
software engineering.)

If you are doing a web application, how are you going to host it? Who
is responsible for managing the web server? Domain name? Firewalls?
Certificates if you need HTTPS rather than plain insecure HTTP.

I have a Raspberry-Pi with Nginx serving static pages over insecure
HTTP as I've never applied for a certificate -- using a dynamic DNS
service. It is not suited for high-demand as it is behind my ISP router,
and my uplink rate is only a tenth of my downlink rate (which isn't the
fastest thing out there to begin with [.Ugh -- Hope it's the weather -- my
downlink is down to 10Mbps, when nominal is closer to 14Mbps]). Someday I
may try creating a Flask application for it, just for learning.


--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On Sun, 23 Jan 2022 at 07:47, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
> If you are doing a web application, how are you going to host it? Who
> is responsible for managing the web server? Domain name? Firewalls?
> Certificates if you need HTTPS rather than plain insecure HTTP.
>
> I have a Raspberry-Pi with Nginx serving static pages over insecure
> HTTP as I've never applied for a certificate -- using a dynamic DNS
> service. It is not suited for high-demand as it is behind my ISP router,
> and my uplink rate is only a tenth of my downlink rate (which isn't the
> fastest thing out there to begin with [.Ugh -- Hope it's the weather -- my
> downlink is down to 10Mbps, when nominal is closer to 14Mbps]). Someday I
> may try creating a Flask application for it, just for learning.
>

Thanks to LetsEncrypt, certificates shouldn't be too hard for any
public-facing server. The Pi can renew and install its own
certificates in a 100% automated process, as long as you can continue
receiving port 80 traffic as well as the port 443 that the live server
would use.

ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
On Sat, 22 Jan 2022 02:22:14 -0800 (PST), NArshad <narshad.380@gmail.com>
declaimed the following:

>
>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

As written, the user will have to know the exact name of the book, as
it exists in the spreadsheet, and enter exactly that...

Is it going to be case sensitive?

A Matter of Life and Death
is not the same as
A Matter Of Life And Death

and partial entries won't match either

A Matter of Life

Do you intend to implement fuzzy logic for finding the target given
partial input? If you do, how do you plan to differentiate between two or
more books that match the logic? Do you strip punctuation?

Most systems will, instead, display a list of all books (unless a
filter is specified -- and may require the user to start with a filter just
to avoid a massive scrolling listing), and let the user select from the
list (radio button, check box, item number). A filter would be <display all
books with all the words "matter", "life" in the name>.


At the level your questions have been -- my biggest suggestion would be
to forget the web form and multi-user problems and write a text-based
console program that can be run from a command line shell. WHEN you get
that working you can consider keeping the logic that interfaces with the
data store, and replace the "presentation" stuff with HTML generation and
web-server integration (any web application will look quite different in
how the code is structured, since a console application has only one flow
-- start the app, make a selection, move to next phase of activity... A web
application has every action as a distinct connection and needs identifying
tokens [cookies] to let the logic know what was done previously)


--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--
https://mail.python.org/mailman/listinfo/python-list
Re: What to write or search on github to get the code for what is written below: [ In reply to ]
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@gmail.com>
To: python-list@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
--
https://mail.python.org/mailman/listinfo/python-list

1 2 3  View All