logo
down
shadow

How can I write to my CSV file in my booking system [STUCK]


How can I write to my CSV file in my booking system [STUCK]

By : code hippy
Date : November 21 2020, 01:01 AM
help you fix your problem I know I sound absolutely stupid but i'm new to Python and as my school project I have to create a cinema booking system. , The seating should be A,1 A,2 etc..
code :
from pprint import pprint as pp
missing = (("B",4),("C",4),("D",4),("E",4))

seats = {(x,y):"x" if (x,y) not in missing else "-" for x in ["A","B","C","D","E"] for y in range(1,8)}

pp(seats)
{('A', '1'): '+',
 ('A', '2'): '+',
 ('A', '3'): '+',
 ('A', '4'): '+',
 ('A', '5'): '+',
 ('A', '6'): '+',
 ('A', '7'): '+',
 ('B', '1'): '+',
 ('B', '2'): '+',
 ('B', '3'): '+',
 ('B', '4'): '-',
 ('B', '5'): '+',
 ('B', '6'): '+',
 ('B', '7'): '+',
 ('C', '1'): '+',
 ('C', '2'): '+',
 ('C', '3'): '+',
 ('C', '4'): '-',
 ('C', '5'): '+',
 ('C', '6'): '+',
 ('C', '7'): '+',
 ('D', '1'): '+',
 ('D', '2'): '+',
 ('D', '3'): '+',
 ('D', '4'): '-',
 ('D', '5'): '+',
 ('D', '6'): '+',
 ('D', '7'): '+',
 ('E', '1'): '+',
 ('E', '2'): '+',
 ('E', '3'): '+',
 ('E', '4'): '-',
 ('E', '5'): '+',
 ('E', '6'): '+',
 ('E', '7'): '+'}
missing = (("B",4),("C",4),("D",4),("E",4))

import os
import pickle
# if file does not exist, this is the first booking
if not os.path.isfile("bookings.pkl"):
    seats = {(x,str(y)):"+" if (x,y) not in missing else "-" for x in ["A","B","C","D","E"] for y in range(1,8)}
else:
    # else use the previous updated dict 
    with open("bookings.pkl") as f:
        seats = pickle.load(f)

while True:
    print("Seats marked + are available\n")
    srt = sorted(seats.iteritems())
    # split into sections based on row and print rows
    sections = [srt[n:n+7] for n in xrange(0,len(srt),7)]
    for sec in sections:
        for seat, status in sec:
             print("{}{}:{status} ".format(*seat,status=status)),
        print("")
    inp = tuple(raw_input("Choose your seat in format row number ie A 1:").upper().split())
    if inp in seats:
        # and not already taken
         if seats[inp] != "*":
            print("You have chosen row: {} seat number: {}\n".format(*inp))
            # ask user to confirm their choice
            confirm = raw_input("Enter y to accept any n to change").lower()
            if confirm == "y":
                seats[inp] = "*"
                with open("bookings.pkl","w") as f:
                    pickle.dump(seats,f)
                    print("Booking confirmed, goodbye.")
                    break
            else:
                 # else let user choose again
                continue
        print("Seat unavailable\n")
    else:
        print("Invalid choice")


Share : facebook icon twitter icon
Online Hotel Booking System, Simultaneous Booking?

Online Hotel Booking System, Simultaneous Booking?


By : user3811195
Date : March 29 2020, 07:55 AM
may help you . Use a locking construct (probably on the database level in this case) to ensure that only one confirmation will go through at once. You should always do this if it's possible to have a race condition like this. That way you will always know who was first, and you can tell the other user that they were too slow to confirm.
Another thing you might want to add is a payment time limit. In many systems, when you confirm something, you will have a certain amount of time to make a payment to get the reservation. If you don't pay within that time, the confirmation will expire and the room will once again be available.
why System.err.println stuck at write?

why System.err.println stuck at write?


By : Matt Banks
Date : March 29 2020, 07:55 AM
like below fixes the issue Most likely what ever is reading System.err isn't consuming the data. Once the buffer fills up, the program will wait until there is space in the buffer to write more.
Argument 1: cannot convert from 'System.Threading.Tasks.Task<Project.Models.Booking>' to Project.Models.Booking

Argument 1: cannot convert from 'System.Threading.Tasks.Task<Project.Models.Booking>' to Project.Models.Booking


By : gunjag
Date : March 29 2020, 07:55 AM
To fix this issue
trying to implement asynchronous methods in my repository classes
code :
public async Task<Booking> CreateBookingAsync(Booking inBooking) {
  Booking booking = new Booking();

  ...

  await AddAsync(booking);
  return booking;
}

[Route("api/PostBooking")]
[HttpPost]
public async Task<IHttpActionResult> PostBooking(BookingSystemServiceBookingViewModel inBooking)
{
  ...

  uw.Services.AddBooking(await uw.Bookings.CreateBookingAsync(booking), inBooking.service.ServiceId);
  uw.Complete();

  return Ok();
}
public Booking CreateBooking(Booking inBooking) {
  Booking booking = new Booking();

  ...

  Add(booking);
  return booking;
}

[Route("api/PostBooking")]
[HttpPost]
public async Task<IHttpActionResult> PostBooking(BookingSystemServiceBookingViewModel inBooking)
{
  ...

  uw.Services.AddBooking(uw.Bookings.CreateBooking(booking), inBooking.service.ServiceId);
  await uw.CompleteAsync();

  return Ok();
}
write batch file to copy a text file from windows system to unix system

write batch file to copy a text file from windows system to unix system


By : user3759487
Date : March 29 2020, 07:55 AM
wish help you to fix your issue PuTTy scp may be an option for you. Works like secure copy on linux.
e.g.
ColdFusion - Booking System - Booking Disappears

ColdFusion - Booking System - Booking Disappears


By : Kuroganashi
Date : March 29 2020, 07:55 AM
around this issue Issue - Race Conditions
The problem is your current code is subject to race conditions. When multiple threads try and read and write a shared resource at the same time, only one of them can win. This is what happens when "John" an "Bob" try and sign up at the exact same time:
code :
    SELECT COUNT(*) AS EnrollmentsFound
    FROM   Enrollment 
    WHERE  courseId = @courseId
    AND    studentId = @studentId 
if ((select count(*) from Enrollment where courseId = @courseId) < @maxCapacity) 
begin
    insert into Enrollment (courseId, studentId )
    values (@courseId, @studentId)
end
<!--- Exclusive lock to prevent race conditions / Access ONLY --->
<cflock name="Student_Enrollment_Add" type="exclusive" timeout="5000">

   <cfquery name="getEnrollments" ...>
      SELECT COUNT(*) AS EnrollmentsFound
      FROM   Enrollment 
      WHERE  courseId = <cfqueryparam value="#form.courseId#" cfsqltype="cf_sql_integer">
   </cfquery>

   <cfif getEnrollments.EnrollmentsFound lt maxCapacity>
       <cfquery ...>
          INSERT INTO Enrollment ( .... )
          VALUES ( .... )
       </cfquery>
   </cfif>

</cflock>
Related Posts Related Posts :
  • Return new instance of subclass when using methods inherited from parent class in Python
  • Which function in django.contrib.auth creates the default model permissions?
  • Formatting text in tabular form with Python
  • How to determine the first day of a month in Python
  • Error while converting date to timestamp in python
  • Python string iterations
  • Is there any file number limitation when you select multiple files with wxFileDialog?
  • Errors with Matplotlib when making an executable with Py2exe (Python)
  • Django Haystack - Indexing single field
  • Go Pro Hero 3 - Streaming video over wifi
  • Appending a column in .csv with Python/Pandas
  • How to change my result directory in Robot framework using RIDE?
  • problem with using pandas to manipulate a big text file in python
  • python-magic module' object has no attribute 'open'
  • Where goes wrong for this High Pass Filter in Python?
  • Why inserting keys in order into a python dict is faster than doint it unordered
  • flann index saving in python
  • Create new instance of list or dictionary without class
  • How can I easily convert FORTRAN code to Python code (real code, not wrappers)
  • Address of lambda function in python
  • Python adding space between characters in string. Most efficient way
  • python http server, multiple simultaneous requests
  • Disguising username & password on distributed python scripts
  • Post GraphQL mutation with Python Requests
  • Why doesnt pandas create an excel file?
  • Rolling comparison between a value and a past window, with percentile/quantile
  • How to avoid repetitive code when defining a new type in python with signature verification
  • How to configure uWSGI in order to debug with pdb (--honour-stdin configuration issue)
  • In Python, how do you execute objects that are functions from a list?
  • Python- Variable Won't Subtract?
  • Processing Power In Python
  • Python 2.7.2 - Cannot import name _random or random from sys
  • Why doesn't the Python sorted function take keyword order instead of reverse?
  • Make a function redirect to other functions depending on a variable
  • get_absolute_url in django-categories
  • Monitoring non-Celery background task with New Relic in Python
  • Feature selection with LinearSVC
  • LSTM - Predicting the same constant values after a while
  • Test the length of elements in a list
  • Django: render radiobutton with 3 columns, cost column must change according to size & quantity selected
  • Python class attributes vs global variable
  • sys.stdout.writelines("hello") and sys.stdout.write("hello")
  • is ndarray faster than recarray access?
  • Python - search through directory trees, rename certain files
  • GAE: How to build a query where a string begins with a value
  • TypeError: __init__() takes at least 2 arguments (1 given)
  • Overriding and customizing "django.contrib.auth.views.login"
  • Django : Redirect to a particular page after login
  • Python search and copy files in directory
  • pretty printing numpy ndarrays using unicode characters
  • Frequent pattern mining in Python
  • How can I make a set of functions that can be used synchronously as well as asynchronously?
  • Convert one dice roll to two dice roll
  • count occourrence in a list
  • Writing an If condition to filter out the first word
  • to read file and compare column in python
  • Install python-numpy in the Virtualenv environment
  • `.select_by_visible_text()` is failed to select element?
  • Unable to send data multiple requests in a single connection — socket error
  • Pandas HDFStore unload dataframe from memory
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org