7 Replies Latest reply: May 25, 2011 4:09 PM by Chris Brain RSS

    Looping through existing table in load script

    Chris Brain

      Would appreciate some help with the following script problem. I am loading a table of tweets using something like:

       

      Timeline:

      LOAD

                text,

                user_id,

                user_name

      FROM

      [http://www.pathtodata.com]

      (txt, utf8, embedded labels, delimiter is '\t', msq);

       

      So at this point I have a table with the columns:

      text     user_id     user_name

       

      But what I want to then do is loop through this table and for each row (text value) I want to make a call to an API which returns the sentiment for the text, so I need to do something like the following pseudo-code:

       

      foreach row in Timeline

       

           Sentiment:

           LOAD

                     status as sentiment_status,

                     text,

                     score as sentiment_score

           FROM

           [http://www.pathtosentimentapi.com/t={row.text}]

           (txt, utf8, embedded labels, delimiter is '\t', msq);

       

      next row

       

      Is this possible and is there a neat way of doing it?