Skip to main content
Question

Merge BLOB data

  • December 6, 2019
  • 2 replies
  • 22 views

oliver.morris
Contributor
Forum|alt.badge.img+14

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.

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

oliver.morris
Contributor
Forum|alt.badge.img+14
  • Author
  • Contributor
  • 176 replies
  • December 6, 2019

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

 


oliver.morris
Contributor
Forum|alt.badge.img+14
  • Author
  • Contributor
  • 176 replies
  • December 6, 2019

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'))