嗨,我是Pig编程新手。我有一个csv文件和制表符作为分隔符。在我的价格栏里我有拉克和克。看起来像这样 40.85 Lacs
, 36.73 Lacs
, 2.01 cr
. 我想像这样转换成十进制
40.85 Lacs - 40,85,000
36.73 Lacs - 36,73,000
2.01 cr - 2,01,00000
我尝试了以下代码:
a = LOAD '/user/user1/input/city/cityname.CSV' using PigStorage('|') as (SourceWebSite:chararray,PropertyID:chararray,ListedOn:chararray,ContactName:chararray,TotalViews:int,Price:chararray,PriceperArea:chararray,NoOfBedRooms:int,NoOfBathRooms:int,FloorNoOfProperty:chararray,TotalFloors:int,Possession:chararray,BuiltUpArea:chararray,Furnished:chararray,Ownership:chararray,NewResale:chararray,Facing:chararray,title:chararray,PropertyAddress:chararray,NearByFacilities:chararray,PropertyFeatures:chararray,Sellerinfo:chararray,Description:chararray);
DUMP a;
b = FOREACH a GENERATE Price;
dump b;
c = FILTER b BY (Price matches '.*Lacs.*');
d = FOREACH c GENERATE Price * 10000.0,SUBSTRING(Price,00000);
d = foreach c generate Price,TOKENIZE(REPLACE(Price,'.','')) AS e;
我在这里挣扎了两天。任何帮助都将不胜感激。
1条答案
按热度按时间vc6uscn91#
使用
REGEX_EXTRACT
若要获取值的第一部分,直到空白,将其转换为BigDigMall,然后将其相乘。使用此输入数据,例如:以下代码将起作用:
结果是: