mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added Code to payloadNames.js and Updated payLoadConverter.py for the Code (#34)
* Added CLSID to payloadNames.js, Updated the payLoadConverter.py so the CLSID can be added, Added 1 custom Loadout in unitPayloads.lue * Added emtpy Loadouts for all aircraft
This commit is contained in:
@@ -4,8 +4,8 @@ import json
|
||||
# Load data from an Excel file
|
||||
df = pd.read_excel('data.xlsx')
|
||||
|
||||
# Group by 'Name', 'Fuel', 'Loadout Name', and 'Roles' and aggregate 'Items - Name' and 'Items - Quantity'
|
||||
grouped = df.groupby(['Name', 'Fuel', 'Loadout Name', 'Roles'])['Items - Name', 'Items - Quantity'].agg(lambda x: list(x)).reset_index()
|
||||
# Group by 'Name', 'Fuel', 'Loadout Name', 'Role', and 'Code' and aggregate 'Items - Name' and 'Items - Quantity'
|
||||
grouped = df.groupby(['Name', 'Fuel', 'Loadout Name', 'Role', 'Code'])['Items - Name', 'Items - Quantity'].agg(lambda x: list(x)).reset_index()
|
||||
|
||||
# Convert the grouped data into the desired format
|
||||
result = {}
|
||||
@@ -24,23 +24,26 @@ for index, row in grouped.iterrows():
|
||||
"quantity": quantity
|
||||
} for item, quantity in zip(row['Items - Name'], row['Items - Quantity'])
|
||||
],
|
||||
"roles": [row['Roles']],
|
||||
"roles": [row['Role']],
|
||||
"code": row['Code'],
|
||||
"loadout_name": row['Loadout Name']
|
||||
}
|
||||
]
|
||||
}
|
||||
else:
|
||||
loadouts = result[name]["loadouts"]
|
||||
loadout = next((l for l in loadouts if l["loadout_name"] == row['Loadout Name']), None)
|
||||
if loadout:
|
||||
loadout["items"] += [
|
||||
{
|
||||
"name": item,
|
||||
"quantity": quantity
|
||||
} for item, quantity in zip(row['Items - Name'], row['Items - Quantity'])
|
||||
]
|
||||
loadout["roles"].append(row['Roles'])
|
||||
else:
|
||||
found = False
|
||||
for loadout in result[name]["loadouts"]:
|
||||
if loadout["fuel"] == row['Fuel'] and loadout["code"] == row['Code'] and loadout["loadout_name"] == row['Loadout Name']:
|
||||
loadout["items"].extend([
|
||||
{
|
||||
"name": item,
|
||||
"quantity": quantity
|
||||
} for item, quantity in zip(row['Items - Name'], row['Items - Quantity'])
|
||||
])
|
||||
loadout["roles"].append(row['Role'])
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
result[name]["loadouts"].append({
|
||||
"fuel": row['Fuel'],
|
||||
"items": [
|
||||
@@ -49,7 +52,8 @@ for index, row in grouped.iterrows():
|
||||
"quantity": quantity
|
||||
} for item, quantity in zip(row['Items - Name'], row['Items - Quantity'])
|
||||
],
|
||||
"roles": [row['Roles']],
|
||||
"roles": [row['Role']],
|
||||
"code": row['Code'],
|
||||
"loadout_name": row['Loadout Name']
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user