Skip to main content

I have a text file which represents a log of activity in using a software licence. The license server records each issue and return of the licence on a seperate line of the file.

 

 

Every day, an entry in the file reads something like "DATESTAMP: YYYYMMDD"

 

Then there are a series of lines which read "TIMESTAMP: HHMMSS"

 

 

What I want to do is associate each timestamp with the latest datestamp to appear above it in the file, and create this as an attribute on each timestamp feature.

 

 

Does anyone have any suggestions?

Thanks in advance, Riley

Hi,

 

 

look into the multiple feature support of the AttributeCreator (http://docs.safe.com/fme/html/FME_Transformers/Default.htm#Transformers/attributecreator.htm), which can reference previous or subsequent features to join your TIMESTAMP features with the preceeding DATESTAMP features.

 

 

David

 

 
Hi David

 

 

Thanks - that's useful, I wasn't aware of that. Unfortunately, I still don't know how many features to tell the AttributeCreator to look backwards for, as this varies depending on the number of licence issues on a given day. Is there a way that I can test for a certain condition within this e.g. contains "datestamp"?

 

 

Thanks, Riley
Hi,

 

 

You can use a txt reader, so it reads textline_data.

 

Expose line_number (if u intend to write it to a textfile again)

 

Connect a stringsearcher with a regexp to find DATESTAMP: (.*)

 

Conne the found port to a variableSetter: variablevalue = matched_parts{0} (this stream does not connect further to anyting, it ends there)

 

 

 

Connect  a variableretriever to the "not found" port and retrieve the variable u set datestamp to and assign it to a attribute (for instance "d_Stamp").

 

 Then connect to a  stringsearcher and serach  for TIMESTAMP: (.*) and assign it (matched_parts{0} ) to a attribute (for instance t_stamp.

 

Now you should have the textfile read an all t_stamps belonging to a d_stamp are related.

 

 

(this is because of sequential reading and the fact that the textfile is ordered)

 

 

 
Gio - this has solved for me. Thank you very much to both of you for quick responses.

Reply