Skip to main content
Hello everyone,

 

 

I have lots of csv files that I need to import. Nonetheless, they are arranged in columns and not in lines, i.e. for one csv I have the following :

 

 

col0(attribute name), col1(attribute value)

 

X,                           1,

 

Y,                            2,

 

Z,                           3,

 

 

In this case, I thus have 3 features with 2 attributes col0 and col1. I want only one feature with 3 attributes X, Y and Z.

 

 

I aggregate and create a list, so I have only 1 feature and then tried two techniques :

 

 

- RecordBuilder

 

- AttributeCreator, by specifying for each attribute X, Y, Z the name as @Value(_list{i}.col0) and the value as _list{i}.col1

 

 

Displaying the result in the FME Viewer shows the calculation succeeded.

 

 

However, the attributes are not created in the workbench so I cannot use them for further process... I tried AttributeExposer but without success.

 

 

thanks in advance for your help.

 

 

Djekko.
Hi Djekko,

 

 

I've thought of this idea: 1) Add a sequencial number (0-based) to each line. 2) Add two attributes: one named "_mod" = count % 3, another named "_id" = count / 3. 3) Divide the flow into 3 flows by "_mod". 4) Rename col1 to x, y, z in each flow. 5) Merge 3 flows by "_id".

 

  There may be more easier way...

 

 

Takashi
Hi,

 

 

Maybe the CAT reader can be of help.
Hi Djekko,

 

 

There could be a more flexible and simple solution with a PythonCaller. For example: -----

 

import fmeobjects   def buildRecord(feature):     name = feature.getAttribute('_row{}.col0')     value = feature.getAttribute('_row{}.col1')     for i in range(len(name)):         feature.setAttribute(nameAi], valueni])

 

-----   Takashi
Ken@Safe provided a quick solution with the BulkAttributeRenamer in the similar question > Attribute renaming using attribute values

 


Thank you for all these proposals, I''ve been quite busy so I had not the time to try them, I'll take a look as soon as possible and give you a feedback.
After several tries, nothing worked out => each time I am unable to get back the new attributes created by the different methods... They are correctly created in the FME Viewer but not propagated in the Workbench to the following transformers.

 

 

I beat the problem from the source by generating all my input csv files in the standard convention, thanks to an update of the soft used to create them.

 

 

Nonetheless, my experience may be useful for other users.

 

 

Thank you for your help and reactivity.

 

 

Cheers,

 

 

Djekko
Hi Djekko,

 

 

Since you can see the attributes in the Viewer, I suppose those are existing indeed - those are only hidden. Try using  the AttributeExposer to expose them.

 

 

Takashi
Hi Djekko,

 

 

If you are using FME 2013 SP2, you can also use the "Multiple Feature Attribute Support" functionality of the AttributeCreator.

 

See more information here.

 

 

Takashi
... sorry, it's not for your question.
You have built attributes dynamically.

 

Those are hidden.

 

If you have only one output schema, you might as well just expose them.

 

You say you tried that, but exposure needs the exact attribute name as you see them in the viewer. This works for me everytime, so should work.

 

 

Recordbuilder builts the attributes, but wont expose them.

 

Alas you cant built an "dynamic" exposer, that would be cool.

 

 

Fame should just stream the dynamic built attributes...the viewer apparently can, so why not?

Reply