I am merging 5 csv files which each contain one field and need to sort them according to the length of the field title. This means I need to first read the attribute name from the csv file and write it to a second file in order to create another field containing the length of that field name. I can´t work out how to expose the attribute name though. Does anyone know how to do this?
1 Answer
This should be easy to do, you just need to "bend the rules". :-)
I'd suggest the following:
- Add CSV reader; set no headers. You should get one attribute called (col0).
- Take the input from this reader and point it to a
Sampler
, keeping only the first feature from each file - The first feature from each file being of course the header, you can now measure their length.
- Feed this number into a
VariableSetter
- All further features from this file go to a
VariableRetriever
to get the Header length. - Use a
Sorter
to sort by that length, which now all features should have.
You'll have to do some stuff to separate by feature-type when things get to the Sorter (be sure to set the CSV reader to use feature-type from filename rather than reader type), but something like that should do it.