Loading ...
Sorry, an error occurred while loading the content.

Re: [ploticus] Reading pipe (|) delimited data with proc getdata

Expand Messages
  • Stephen C. Grubb
    Hi, proc getdata parses the data into fields before doing filter processing.. thus you can t use filter to perform field delimitation. If you re on a
    Message 1 of 2 , Dec 7, 2004
    • 0 Attachment
      Hi,

      proc getdata parses the data into fields before doing filter processing..
      thus you can't use filter to perform field delimitation.

      If you're on a unix/linux type operating system you can do something like
      this

      #proc getdata
      command: cat mydatafile | sed "s/|/ /g"
      delim: tab
      ...


      Steve



      On Sat, 4 Dec 2004, yannbrolec wrote:

      >
      >
      > I try to read input data which are pipe delimited. I used the filter
      > feature in proc getdata in order to parse it. The trouble is that ,
      > instead of getting the desired fields in the output, I can only get a
      > one field (with the variables concatenated in it).
      >
      > Here is the script :
      >
      > #proc getdata
      > file: 1
      > standardinput: no
      > delim: tab
      > fieldnameheader: no
      > pf_fieldnames: item rate
      > filter: ##set first = $contains( "|", @@1)
      > ##set long = $arith(@@first-1)
      > ##set item = $substring( @@1, 1, @@long)
      > ##set next = $arith(@@first+1)
      > ##set suite = $substring( @@1, @@next, 99)
      > ##set second = $contains( "|", @@suite)
      > ##set long = $arith(@@second-1)
      > ##set rate = $substring( @@suite, 1, @@long)
      > ##print @@item @@rate
      >
      > showresults: yes
      >
      > #exit
      >
      > (note -> I use the delim: tab feature because there could be commas or
      > blanks inside, see hereafter)
      >
      > and here is the input data :
      >
      > What is your favourite scripting language?|987442734|1006727028|0|0|1
      > PHP|66|red
      > Perl|34|orange
      > ASP|17|green
      > JSP|21|purple
      > Python|7|gold
      > other|16|aqua
      >
      > What I get for the second row, for example, is [PHP 66 ] instead of
      > [PHP] [66]
      >
      > Any idea ? Of course it would be nice if pipe delimited data could be
      > directly read using proc getdata !
      >
      > Additional question : to bypass the problem I tried to make a first
      > proc getdata translating | to tab and then output the tab using #cat
      > file1 ,
      > so as to read it in a second proc getdata, but the #cat doesn't seem
      > to work for me ...
      >
      > Sorry for the poor english and the naive questions, I'm a newbie in it
      > and not a programer at all ...
      >
      > Best regards
      >
      >
      >
      >
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      >


      Stephen C. Grubb scg@...
      Scientific Software Engineer, The Jackson Laboratory
      600 Main Street Bar Harbor, Maine 04609 USA
    Your message has been successfully submitted and would be delivered to recipients shortly.