diff --git a/efo/data/efo_taskconcept_pubmed_hits.csv b/efo/data/efo_taskconcept_pubmed_hits.csv index 86180bb..bf9158f 100644 --- a/efo/data/efo_taskconcept_pubmed_hits.csv +++ b/efo/data/efo_taskconcept_pubmed_hits.csv @@ -2679,7 +2679,6 @@ More Less Odd Even,Verbal Processing,0,0,316,1578856895271 More Less Odd Even,Visuospatial Processing,0,0,562,1578856899218 More Less Odd Even,Volition,0,0,848,1578856903140 -task,concept,hits,suffixed_hits,concept_hits,timestamp_ms Analogy Making,Behavioral Control,0,0,2305,1578857104972 Analogy Making,Behavioral Regulation,0,0,650,1578857108688 Analogy Making,Central Executive,0,0,951,1578857112503 diff --git a/efo/data/efo_taskconcept_pubmed_hits.csv b/efo/data/efo_taskconcept_pubmed_hits.csv index 86180bb..bf9158f 100644 --- a/efo/data/efo_taskconcept_pubmed_hits.csv +++ b/efo/data/efo_taskconcept_pubmed_hits.csv @@ -2679,7 +2679,6 @@ More Less Odd Even,Verbal Processing,0,0,316,1578856895271 More Less Odd Even,Visuospatial Processing,0,0,562,1578856899218 More Less Odd Even,Volition,0,0,848,1578856903140 -task,concept,hits,suffixed_hits,concept_hits,timestamp_ms Analogy Making,Behavioral Control,0,0,2305,1578857104972 Analogy Making,Behavioral Regulation,0,0,650,1578857108688 Analogy Making,Central Executive,0,0,951,1578857112503 diff --git a/efo/fetch_efo_ontology_from_pubmed.py b/efo/fetch_efo_ontology_from_pubmed.py index 41c4990..729e051 100644 --- a/efo/fetch_efo_ontology_from_pubmed.py +++ b/efo/fetch_efo_ontology_from_pubmed.py @@ -16,6 +16,8 @@ import pandas as pd +import os + owl_path = "file:///Users/morteza/workspace/ontologies/efo.owl" owl_prefix = "http://www.semanticweb.org/morteza/ontologies/2019/11/executive-functions-ontology#" @@ -136,11 +138,18 @@ try: data = pd.read_csv(csv_file) except: data = pd.DataFrame({'task':[],'concept':[]}) - with open(csv_file, "a+",buffering=1) as csv: + # create file and headers if does not exist + if not os.path.exists(csv_file): + with open(csv_file, 'w'): pass + + with open(csv_file, "r+") as csv: if len(csv.read()) == 0: print("Empty csv found, generating csv headers...") csv.write(csv_header() + '\n') + # write queries into the file + with open(csv_file, "a+",buffering=1) as csv: + for task, concept in [(task, concept) for task in tasks for concept in concepts]: previously_stored = data[(data.task == task) & (data.concept == concept)] if previously_stored.empty: