Question

Merge BLOB data

  • 6 December 2019
  • 2 replies
  • 3 views

Badge +10

Hi, I would like to merge some blob data in an attribute based on if it shares the same id, the merge also needs to happen in the correct order and I have another field with that order. Does anyone know how I would go about this. The data does not have any geometries.

Thank you for your help in advance.

 


2 replies

Badge +10

I try to use the aggregator but that turns the blob into a string and the data type changes. Anything I can do to get round this?

 

Thank you

 

Badge +10

I tried instead to join the blob content in python, merging then the shape set is the same. This works for 1 feature then stops. Any idea what could be wrong with my python such that it doesnt iterate through each shape set. Thank you

 

import fme
import fmeobjects

class FeatureProcessor(object):
    def __init__(self):
        self.attribute_list = []
    def input(self,feature):
        attribute_list = processFeature(self,feature)
    def close(self):
        shape_vec_bytes=b''
        previous_id = 0
        attribute_list_b = []

        for shape_set_id1,byte_data1 in self.attribute_list:
            if shape_set_id1 == previous_id:
                shape_vec_bytes = shape_vec_bytes + byte_data1
                previous_id = shape_set_id1
            else:
                shape_vec_bytes = byte_data1
                previous_id = shape_set_id1
           
        attribute_list_b.append((shape_set_id1,shape_vec_bytes))
           
        for shape_set_id2,shape_vec_bytes2 in attribute_list_b:
            newFeature = fmeobjects.FMEFeature()        
            newFeature.setAttribute('gsnv_blob_data', shape_vec_bytes2)
            newFeature.setAttribute('shape_set_id', shape_set_id2)
            self.pyoutput(newFeature)

def processFeature(self,feature):
    byte_data = feature.getAttribute('GSNV_BLOB_DATA')
    shape_set_id = feature.getAttribute('SHAPE_SET_ID')
    try:    
        self.attribute_list.append((shape_set_id,byte_data))
    except ValueError:
        print(feature.getAttribute('SHAPE_SET_ID'))
       

 

 

 

 

Reply