使用PIG

时间:2017-07-06 11:16:21

标签: csv apache-pig whitespace

我有逗号(,)分隔(csv)数据集。我想在Pig脚本中删除每个分隔符后面有空格的地方。示例行如下所示:

"Sachin", "India", "batsaman", "99", "kolkata", " ", "xyz"

在逗号后删除空格后,它应该如下所示:

"Sachin","India","batsaman","99","kolkata"," ","xyz"

1 个答案:

答案 0 :(得分:1)

将其加载到单个字段中并使用REPLACE。

A = LOAD 'data.txt' USING TextLoader();
B = FOREACH A GENERATE REPLACE($0,' ','');