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": , 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)