-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
I wrote this basic python code with chatgpt to fix a bug where the json is full of misalignments and "\n"s when pasting it from age4builder.com.
Instructions:
You have to copy the aoe4 build into your clipboard, run this code within a python terminal and then paste it into age4builder. Obviously the modules (json, pyperclip) have to be installed before as well. Enjoy :)
import json
import pyperclip
# Read data from clipboard
clipboard_data = pyperclip.paste()
data = json.loads(clipboard_data)
# Process data
for item in data["build_order"]:
item["notes"] = [note.replace("\n", "") for note in item["notes"]]
item["notes"] = [note.replace(" ", "") for note in item["notes"]]
# Copy updated data to clipboard
updated_data = json.dumps(data, indent=4)
pyperclip.copy(updated_data)
"""
This code uses the pyperclip module to read the data from the clipboard using the pyperclip.paste() method.
It then processes the data using the same loop as before to remove the newline characters from the "notes" field.
Finally, it uses the json.dumps() method to pretty-print the updated data with the indent parameter set to 4,
and then copies the updated data back to the clipboard using the pyperclip.copy() method.
"""
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels