Variable length csv

Hi,

I have a csv file where data is organised in the may formats:

format1:

value1, value2, value3,value4

format2:

value1, value2, value3, keyX:valueX,keyY:valueY,keyZ:valueZ..

in the 2nd format my key:value will be of variable length..

How to write filters that can accomodate these two ?

From your formats listed, I assume that the first 3 fields are definitely CSV and the fourth field is either a value or a KV set.

You have a few options.

  1. Use the CSV filter, defining 4 columns. Then in an if block test whether the fourth field contains a : colon (presuming that a non KV type fourth field does cannot have a colon in it). Then in the if block use the KV filter to split the keys and values on the colon.
  2. If the first three field's values can never have a , comma in them (even in quotes), use the Dissect filter to split the 4 fields. Then use the if block and KV filter as above.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.