7

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?

4

This should be easy to do, you just need to "bend the rules". :-)

I'd suggest the following:

  1. Add CSV reader; set no headers. You should get one attribute called (col0).
  2. Take the input from this reader and point it to a Sampler, keeping only the first feature from each file
  3. The first feature from each file being of course the header, you can now measure their length.
  4. Feed this number into a VariableSetter
  5. All further features from this file go to a VariableRetriever to get the Header length.
  6. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.