apache-pig LOAD Operator Loading Stock market data


Example

Let us assume the following stock market data stored in HDFS. It is a CSV file with fields: Symbol, Date, Open, High, Close & Volume.

ABT,20160106,42.310001,42.98,42.209999,42.560001,5906000
BAC,20160201,14.05,14.09,13.8,13.96,105739400
CAS,20160129,1.9,1.97,1.83,1.84,34500
DCA,20160129,3.46,3.54,3.46,3.51,84600
ECL,20160114,103.480003,105.400002,102.480003,104.82,1485000
FAF,20160201,34.040001,34.82,33.939999,34.639999,1222600
TYL,20160201,156.070007,159.550003,155.690002,158.259995,177100
UTL,20160201,38.610001,39.889999,38.57,39.27,119500
VTR,20160128,54.09,54.73,53.549999,53.790001,2441300
WWE,20160201,17.629999,18,17.27,17.799999,734100
XRX,20160104,10.41,10.43,10.13,10.3,9122600
YUM,20160104,71.32,72.25,70.639999,72.209999,3466300
ZTR,20160104,12.1,12.14,11.98,12.11,60200

Example 1 A simple LOAD statement for the above data would look like:

stocks = load '/user/pig/stock.txt' using PigStorage(',') as 
             (sym:chararray, date:int, open:float, high:float, low:float, 
              close:float, vol:int);