Skip to content

Commit

Permalink
fix: flickr mapping return pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieboldianus committed Aug 27, 2019
1 parent beaf45b commit 393d708
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lbsntransform/classes/field_mapping_flickr.py
Expand Up @@ -46,7 +46,7 @@ def __init__(self,
self.origin = origin
self.null_island = 0
# this is where all the data will be stored
self.lbsn_records = LBSNRecordDicts()
self.lbsn_records = []
self.log = logging.getLogger('__main__') # get the main logger object
self.skipped_count = 0
self.skipped_low_geoaccuracy = 0
Expand All @@ -62,12 +62,14 @@ def parse_csv_record(self, record):
Attributes:
record A single row from CSV, stored as list type.
"""
self.lbsn_records.clear()
if len(record) < 12 or not record[0].isdigit():
# skip
self.skipped_count += 1
return
else:
self.extract_flickr_post(record)
return self.lbsn_records

def extract_flickr_post(self, record):
"""Main function for processing Flickr CSV entry.
Expand All @@ -93,7 +95,7 @@ def extract_flickr_post(self, record):
user_record.url = f'http://www.flickr.com/photos/{user_record.pkey.id}/'
if user_record:
post_record.user_pkey.CopyFrom(user_record.pkey)
self.lbsn_records.add_records_to_dict(user_record)
self.lbsn_records.append(user_record)
post_record.post_latlng = self.flickr_extract_postlatlng(record)
geoaccuracy = FieldMappingFlickr.flickr_map_geoaccuracy(record[13])
if geoaccuracy:
Expand All @@ -105,7 +107,7 @@ def extract_flickr_post(self, record):
place_record = HF.new_lbsn_record_with_id(Place(),
record[19],
self.origin)
self.lbsn_records.add_records_to_dict(place_record)
self.lbsn_records.append(place_record)
post_record.place_pkey.CopyFrom(place_record.pkey)
post_record.post_publish_date.CopyFrom(
HF.parse_csv_datestring_to_protobuf(record[9]))
Expand Down Expand Up @@ -134,7 +136,7 @@ def value_count(x): return int(x) if x.isdigit() else 0
else:
post_record.post_type = Post.IMAGE
post_record.post_content_license = value_count(record[14])
self.lbsn_records.add_records_to_dict(post_record)
self.lbsn_records.append(post_record)

@staticmethod
def reverse_csv_comma_replace(csv_string):
Expand Down

0 comments on commit 393d708

Please sign in to comment.