data = load 'commatest.csv' using PigStorage(';') as (f1:chararray, f2:chararray, f3:chararray);
replaced = foreach data generate REPLACE(f1, ',', '.') as f1dot, REPLACE(f2, ',', '.') as f2dot, REPLACE(f3, ',', '.') as f3dot;
fdata = foreach replaced generate (float)f1dot as f1, (float)f2dot as f2, (float)f3dot as f3;
dump fdata;
输出:
(1.2,2.3,4.5)
(5.6,6.7,7.8)
要测试它是否真的转换为float:
test = foreach fdata generate f1*f2*f3;
dump test;
1条答案
按热度按时间toe950271#
好吧,用一些简单的数据来测试一下:
Pig脚本:
输出:
要测试它是否真的转换为float:
输出: