Skip to main content

Hello,

Trying to setup a process to parse and load IIS log files to a database to monitor errors on a Geocortex site.

I have a workspace that returns the file path of the most recent log file and that is passed into a FeatureReader with the CSV reader.

The data is space delimited. The issue is that the field name header has one extra field (X). So when the text file is parsed, the field names are offset one column to the right.

 

Header: X |1|2|3|4|5

Data: 1|2|3|4|5|

I need to remove X in the Field name header, and shift the header one cell to the left.

Ideally this could be done in the CSV reader, but I don't see how.

Thanks for the help. Much appreciated.

-R

 

Is it too simplistic to suggest you skip row 1 all together and then just have an AttributeManager straight after to map col0 to appropriate value, col1 etc. Hardcoded admittedly but gets the job done.


I think that may be the only solution. But I was hoping it wasn't 🙂.


You could do it dynamically with a pythonCreator

import fmeobjects

class FeatureCreator(object):
    def input(self,feature):
        f = open(FME_MacroValues 'SourceDataset_TEXTLINE'],'r')
        header = f.readline()
        attributes = header.split() 1:]  #drop first element
        ct = len(attributes)
        for line in f:
            values = line.split()
            newFeature = fmeobjects.FMEFeature()
            for i in range(ct):
                newFeature.setAttribute(attributesri],valuesÂi])
            self.pyoutput(newFeature)

You would still need to expose the attributes manually to use them on the canvas


Hi @ogc_ryan I was able to remove the X field from the header when adding a new CSV reader. When you edit the CSV parameters, first change the Attribute Definition to Manual. Un-check X. Under Fields, set "Field Names Line" to "None". Then reset "Data Start Line" to 2.


Reply