Skip to content

Commit

Permalink
Merge pull request #71 from robertatakenaka/melhora_get_doc_records
Browse files Browse the repository at this point in the history
Cria id2json3.get_doc_records
  • Loading branch information
robertatakenaka authored Dec 15, 2024
2 parents d62b3cd + e348459 commit b3f0117
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions scielo_classic_website/iid2json/id2json3.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ def pids_and_their_records(id_file_path, db_type):
return _get_id_and_json_records(records, id_function)


def get_doc_records(id_file_path):
issues = {}
for item_id, records in pids_and_their_records(id_file_path, "artigo"):
record_type = None
if records:
record_type = _get_value(records[0], "v706")

if record_type == "i":
issues[item_id] = records[0]
elif record_type == "o":
if len(item_id) == 23:
i_id = item_id[1:18]
yield {"issue_id": i_id, "doc_id": item_id, "issue": issues.get(i_id), "article": records}
else:
yield {"invalid_records": True, "item_id": item_id, "records": records}
else:
yield {"invalid_records": True, "item_id": item_id, "records": records}


def _get_value(data, tag):
"""
Returns first value of field `tag`
Expand Down

0 comments on commit b3f0117

Please sign in to comment.