![]() The items() API takes a query string that tells you which part of the record to return. With this API the file has to stay open because the JSON parser is reading from the file on demand, as we iterate over the records. ![]() In the previous version, using the standard library, once the data is loaded we no longer to keep the file open. items ( f, "item" ): user = record repo = record if user not in user_to_repos : user_to_repos = set () user_to_repos. Import ijson user_to_repos = with open ( "large-file.json", "rb" ) as f : for record in ijson. There are a number of Python libraries that support this style of JSON parsing in the following example, I used the ijson library.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |