Database Reference
In-Depth Information
Figure 9.22 Input traffic data
Open your favorite text editor and enter the following code. Make sure to
pay attention to the indenting:
#!/usr/bin/env python
import sys
for line in sys.stdin.readlines():
line = line.strip()
fields = line.split('\t')
time = fields[0]
sensor= fields[1]
maxvalue = max(fields[2:5])
print time,"\t",sensor,"\t",maxvalue
Save the file as get_maxValue.py in a reachable folder (for example,
C:\SampleData ). In the Hive command-line console, create a speeds
table and load the data from traffic.txt into it:
CREATE TABLE speeds(recdate string, sensor string, v1
double, v2 double,
v3 double, v4 double) ROW FORMAT DELIMITED FIELDS
TERMINATED BY '\t';
LOAD DATA LOCAL INPATH 'c:\sampledata\traffic.txt'
OVERWRITE INTO TABLE speeds;
 
Search WWH ::




Custom Search