Created
October 19, 2022 03:24
-
-
Save hargup/017c83b24b2bb23a3986eb80349ca220 to your computer and use it in GitHub Desktop.
Validate if a file a valid jsonl file
This file contains 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 fileinput | |
import json | |
def valid_json(json_str): | |
try: | |
json.loads(json_str) | |
return True | |
except: | |
return False | |
return True | |
for ln, line in enumerate(fileinput.input()): | |
if not valid_json(line): | |
print("Error in line %s" % str(ln+1)) | |
print("line: %s" % line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment