Python Forum
how to put text file in a dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to put text file in a dictionary
#1
A library maintains its book information (stock) in a text file. An application needs to be developed which will read the text file and display all the books available for borrowing. Then with each transaction (borrowing) a note should be generated for the particular borrower and should be written into a file. The stock of the books should also be updated after each transaction. For example, if the library had 10 books of specific title, then if one of those books is borrowed then the number should change to 9. In the case of returning a book, a note should again be generated for the person returning the book. The stock should also be updated i.e. the quantity of the book returned should be increased by 1. A sample format of the text file containing the information about the books is as follows:
Harry Potter, JK Rowling, 30, $2
Start With Why, Simon Sinek, 10, $1.5
Programming With Python, John Smith, 20, $1.5

*1st column contains the name of the book, 2nd column contains the name of the author, 3rd column contains the quantity available, 4h column contains the price for borrowing the book (for duration of 10 days) **You can use your own format and add other information too A note should be generated for each transaction. When a person borrows a book a note should be generated which must contain the name of the borrower, the name of the book borrowed, the date and time of such issue and the total amount to be paid for the borrowing. If a person decides to borrow multiple books then all the borrowed books should be written to the note and the amount should be added up for all the borrowed books. When a person returns a book to the library, a note should be generated and written to the file again. The note should contain the name of the borrower, name of the book, date and time of the return. The lending duration should be set to 10 days, and a person is late in return the book, a fine should be applied on a daily basis which should also be present in the generated file.
Reply
#2
What have you tride? We're not going to write your code for you, but we would be glad to help you fix your code when you run into problems. When you do run into problems, be sure to post your code in Python tags, and clearly explain the problem you are having, including the full text of any errors.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
I didn't read through that whole thing but it looks like you just copy-pasted your homework. We're not going to do it for you, but we would love to help. What you need to do is give it a try, and then when you get stuck, post your code (in code tags) along expected vs. actual output (hard-coded any relevant inputs). Usually no more than 5-10 lines are needed to demonstrate a problem, even for large code. The more simplified your question, the more likely you'll get a speedy and helpful reply.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  dictionary output to text file (beginner) Delg_Dankil 2 1,131 Jul-12-2023, 11:45 AM
Last Post: deanhystad
  Using dictionary to find the most sent emails from a file siliusu 6 7,451 Apr-22-2021, 06:07 PM
Last Post: siliusu
  Updating dictionary in another py file tommy_voet 1 4,779 Mar-28-2021, 07:25 PM
Last Post: buran
  Making a dictionary from a file instyabam 0 1,481 Oct-27-2020, 11:59 AM
Last Post: instyabam
  how can i create a dictionary of dictionaries from a file Astone 2 2,209 Oct-26-2020, 02:40 PM
Last Post: DeaD_EyE
  Convert all actions through functions, fill the dictionary from a file Astone 3 2,369 Oct-26-2020, 09:11 AM
Last Post: DeaD_EyE
  Convert text from an image to a text file Evil_Patrick 5 4,217 Jul-30-2019, 07:57 PM
Last Post: DeaD_EyE
  reading text file and writing to an output file precedded by line numbers kannan 7 10,247 Dec-11-2018, 02:19 PM
Last Post: ichabod801
  Dictionary to .txt or .csv file stanthaman42 9 4,562 Aug-08-2018, 03:37 PM
Last Post: Vysero
  dictionary from file Zatoichi 5 3,774 Feb-11-2018, 07:15 PM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020