Created
May 11, 2023 03:08
-
-
Save aofarrel/6206913f620e8a1ebea17f3ec0d3d087 to your computer and use it in GitHub Desktop.
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 os | |
| import json | |
| lazy_array_of_strings_to_write = [] | |
| for file in os.listdir("rand12344"): | |
| if file.endswith(".json"): | |
| sample = file.rstrip("._to_Ref.H37Rv.bam.results.json") | |
| with open(f"rand12344/{file}") as thisjson: | |
| data = json.load(thisjson) | |
| strain = data["sublin"] | |
| lazy_array_of_strings_to_write.append(f"{sample}\t{strain}\n") | |
| with open("strains_from_jsons.tsv", "w") as outfile: | |
| for thingy in lazy_array_of_strings_to_write: | |
| outfile.write(thingy) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment