diff options
author | gilad_ilsar <gandismidas1> | 2016-09-22 16:55:33 +0300 |
---|---|---|
committer | gilad_ilsar <gandismidas1> | 2016-09-22 16:55:33 +0300 |
commit | a59d8c977eac3eb5c71870815730e4c9bf35bad2 (patch) | |
tree | 9bf395039f55e54de512f84f20c20b93a460b977 /entities | |
parent | 3615e3968baa5a464a2725e280a7e0f89e3428cf (diff) |
parser into csv
Diffstat (limited to 'entities')
-rw-r--r-- | entities/location.py | 10 | ||||
-rw-r--r-- | entities/person.py | 8 |
2 files changed, 18 insertions, 0 deletions
diff --git a/entities/location.py b/entities/location.py index 064b193..a43eb8d 100644 --- a/entities/location.py +++ b/entities/location.py @@ -1,3 +1,5 @@ +import json + from entities.basic_entity import BasicEntity @@ -8,8 +10,16 @@ class Location(BasicEntity): self.name_in_langs = name_in_langs self.comments_list = comments_list + CSV_FIELDS = ["name", "comments"] + TYPE = "LOCATION" + + def print_entity(self): print("Name = " + self.name) print("Name in langs = " + str(self.name_in_langs)) print("Types = " + str(self.types_of_place)) print("Comments = " + str(self.comments_list)) + + def to_csv_dict(self): + return {'name': self.name, + 'comments': json.dumps(self.comments_list, ensure_ascii=False)} diff --git a/entities/person.py b/entities/person.py index c6db584..b315aac 100644 --- a/entities/person.py +++ b/entities/person.py @@ -1,3 +1,5 @@ +import json + from entities.basic_entity import BasicEntity @@ -57,6 +59,8 @@ class Person(BasicEntity): self.comments_list = comments_list self.profession = profession + CSV_FIELDS = ["name", "biodata", "comments"] + TYPE = 'PERSON' def print_entity(self): print("Name = " + self.name) @@ -66,3 +70,7 @@ class Person(BasicEntity): print("Bio Data = " + str(self.bio_data)) print("Comments = " + str(self.comments_list)) print("Profession = " + str(self.profession)) + + def to_csv_dict(self): + return {'name': self.name, 'biodata': self.bio_data, + 'comments': json.dumps(self.comments_list, ensure_ascii=False)} |