Commit ef70a1a2 authored by ajil.k's avatar ajil.k

updated the integrated code with all modules

parent 3e0b3640
......@@ -10,56 +10,6 @@
"column7": "age"
},
"body": [
{
"booking_id": 5,
"mobile_no": 46356754,
"no_of_tickets": 1,
"date_of_purchase": "2023-02-14",
"deleted": true,
"preferred_class": "silver",
"seat_numbers": "40",
"age": 30
},
{
"booking_id": 6,
"mobile_no": 76788655566,
"no_of_tickets": 2,
"date_of_purchase": "2023-02-14",
"deleted": true,
"preferred_class": "gold",
"seat_numbers": "209,210",
"age": 66
},
{
"booking_id": 4,
"mobile_no": 33332233450,
"no_of_tickets": 5,
"date_of_purchase": "2023-02-14",
"deleted": true,
"preferred_class": "gold",
"seat_numbers": "20,21,22,23,24",
"age": 30
},
{
"booking_id": 8,
"mobile_no": 7766554433,
"no_of_tickets": 2,
"date_of_purchase": "2023-02-14",
"deleted": true,
"preferred_class": "silver",
"seat_numbers": "101,100",
"age": 67
},
{
"booking_id": 7,
"mobile_no": 7766554433,
"no_of_tickets": 2,
"date_of_purchase": "2023-02-14",
"deleted": true,
"preferred_class": "silver",
"seat_numbers": "99,98",
"age": 67
},
{
"booking_id": 1,
"mobile_no": 786545676,
......
......@@ -121,14 +121,14 @@ class Tickets:
logger.error(e)
@staticmethod
def json_data(dataframe):
def json_data(filename, dataframe):
try:
dataframe["date_of_purchase"] = dataframe["date_of_purchase"].dt.strftime('%Y-%m-%d')
keys = [f"column{i}" for i in range(len(dataframe.columns))]
header_dict = {'header': dict(zip(keys, dataframe.columns))}
data = {"body": dataframe.to_dict(orient='records')}
json_dict = {**header_dict, **data}
with open("external/bookings.json", "w") as json_file:
with open(f"external/{filename}.json", "w") as json_file:
json.dump(json_dict, json_file, indent=4)
return json_dict
except Exception as e:
......
......@@ -65,7 +65,8 @@ def generate_seats():
async def booking_details_json_format(file: UploadFile):
try:
excel_file = pd.read_excel(await file.read())
message = Tickets().json_data(excel_file)
excel_filename = file.filename
message = Tickets().json_data(excel_filename, excel_file)
return message
except Exception as e:
logger.error(e)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment