Created
October 4, 2023 10:07
-
-
Save mkubdev/bd1c3c66fb1af0b69f19b602b0ce3899 to your computer and use it in GitHub Desktop.
Fix json of an exported mongo collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| # Read the incorrect JSON file | |
| with open('jobs.json', 'r') as file: | |
| data = file.read() | |
| # Add commas between documents | |
| fixed_data = re.sub(r'}\s*{', '},\n{', data) | |
| # Write the fixed JSON to a new file | |
| with open('fixed_file.json', 'w') as file: | |
| file.write(fixed_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment