mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Merge pull request #24 from WoodyXP/main
First Set of Hardcoded Loadouts according to the unitTypes.ts
This commit is contained in:
commit
ed12caeb0b
57
scripts/payLoadConverter.py
Normal file
57
scripts/payLoadConverter.py
Normal file
@ -0,0 +1,57 @@
|
||||
import pandas as pd
|
||||
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()
|
||||
|
||||
# Convert the grouped data into the desired format
|
||||
result = {}
|
||||
for index, row in grouped.iterrows():
|
||||
name = row['Name']
|
||||
if name not in result:
|
||||
result[name] = {
|
||||
"name": row['Name'],
|
||||
"label": row['Name'],
|
||||
"loadouts": [
|
||||
{
|
||||
"fuel": row['Fuel'],
|
||||
"items": [
|
||||
{
|
||||
"name": item,
|
||||
"quantity": quantity
|
||||
} for item, quantity in zip(row['Items - Name'], row['Items - Quantity'])
|
||||
],
|
||||
"roles": [row['Roles']],
|
||||
"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:
|
||||
result[name]["loadouts"].append({
|
||||
"fuel": row['Fuel'],
|
||||
"items": [
|
||||
{
|
||||
"name": item,
|
||||
"quantity": quantity
|
||||
} for item, quantity in zip(row['Items - Name'], row['Items - Quantity'])
|
||||
],
|
||||
"roles": [row['Roles']],
|
||||
"loadout_name": row['Loadout Name']
|
||||
})
|
||||
|
||||
# Print the result with the correct indents
|
||||
print(json.dumps(result, indent=2))
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user