38087-vm/fix_seeder.py
2026-02-05 06:00:46 +00:00

27 lines
608 B
Python

import re
file_path = 'backend/src/db/seeders/20231127130745-sample-data.js'
with open(file_path, 'r') as f:
content = f.read()
# Pattern to remove "id": <number>, lines
# We handle potential indentation and trailing commas
# regex:
# ^ start of line
# \s* whitespace
# "id": "id" key
# \s* whitespace
# \d+ integer
# \s* whitespace
# ,? optional comma
# \s* whitespace
# $ end of line
pattern = r'^\s*"id":\s*\d+\s*,?\s*$'
# We need re.MULTILINE to match ^ and $ for each line
new_content = re.sub(pattern, '', content, flags=re.MULTILINE)
with open(file_path, 'w') as f:
f.write(new_content)