Converts XML file to JSON and saves the output.
(xml_path, output_path)
| 15 | |
| 16 | |
| 17 | def convert_xml_to_json(xml_path, output_path): |
| 18 | """Converts XML file to JSON and saves the output.""" |
| 19 | if not os.path.exists(xml_path): |
| 20 | print(f"Error: File not found - {xml_path}") |
| 21 | return None |
| 22 | |
| 23 | json_data = xml_to_json(xml_path) |
| 24 | if json_data: |
| 25 | with open(output_path, "w", encoding="utf-8") as f: |
| 26 | json.dump(json_data, f, ensure_ascii=False, indent=2) |
| 27 | print(f"JSON file created: {output_path}") |
| 28 | return json_data |
| 29 | else: |
| 30 | print("Failed to create JSON data") |
| 31 | return None |
| 32 | |
| 33 | |
| 34 | def process_in_batches(tx, query, data, batch_size): |