2 Replies Latest reply on Aug 27, 2014 1:56 PM by David Muench

    Having problems writing a pipe delimited grammar

    David Muench

      I'm trying to write a new grammar in BSA for a pipe delimited format - it is basically CSV with pipe characters (|) instead of commas, and has a trailing pipe at the end of the line. Here is an example, the number of fields is always the same:


      host1|host3|host4|host3|-sp -Is -E -R -r1 -Ts 43200 -pl 300|D|33000|5.4|Some comment sentence|


      I started by modifying a copy of the csv grammar but that quickly got confusing with recursion errors. So I switched tactics and based it off of the group.gm grammar with the number of fields hard coded. Here is what I have at the moment:




      VAR_PIPE |




      VAL [^\|]*

      KEY ^[A-Za-z0-9]+

      COMMENT #.*

      PIPE \|




      comment COMMENT $save_as_comment $0


      record KEY PIPE VAL PIPE VAL PIPE VAL PIPE VAL PIPE VAL PIPE VAL PIPE VAL PIPE VAL PIPE $new_field $0 $new_field $2 $new_field $4 $new_field $6 $new_field $8 $new_field $10 $new_field $12 $new_field $14 $new_field $16 $save_record $0




      #add $write_record $VAR_PIPE

      I'm not worried about modifying the files yet so I have the add statement commented out. The grammar will pick up the first entry and put it in the name column, but it won't populate any of the value columns. I am out of ideas at this point - the sequence of regex's match the data when I use a tool to test it, but it isn't working the way I expect in BSA. Any help would be appreciated.