2 Replies Latest reply: Oct 17, 2012 5:02 PM by Rob Wunderlich RSS

    Scripting

    Hardik Gandhi

      Hi,

       

      I loading a shipping table. There are few fields in shipping table that stores information as '0' and '1'. I would like to rename '0' as 'No' and '1' as 'Yes'.

       

      i.e. Field Name - Shipped: Rename '0' as 'Not Shipped' and '1' as 'Shipped'

       

      Regards,

      H

        • Re: Scripting
          Stefan Wühl

          Try

           

          LOAD

          if(Shipped,'Shipped','Not Shipped') as Shipped,

          ...

          FROM YourTable;

           

          or using a mapping table:

           

          MAP:

          MAPPING LOAD * INLINE [

          F1, F2

          0,Not Shipped

          1,Shipped

          ];

           

          LOAD

          applymap('MAP',Shipped,'unknown status') as Shipped,

          ...

          FROM YourTable;

            • Re: Scripting
              Rob Wunderlich

              Perhaps more than the OP asked for, but I like to load or map as a dual. That way you get "Yes" / "No" in display fields (like listboxes and table columns) but still retain the the ability to use expressions like

               

              =sum(Shipped)

              -if(Shipped,...

               

              Create the mapping table like this:

               

              YesNoMap:

              MAPPING

              LOAD from, dual(to,from) INLINE [

              from, to

              0, No

              1, Yes

              ];

               

              Map Shipped USING YesNoMap;

               

              -Rob

              http://robwunderlich.com