作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我是 PIG 的新手,有人可以帮助我如何加载一个包含多个字符(在我的例子中为“^^”)作为列分隔符的文件。
例如我有以下列的文件aisforapple^^bisforball^^cisforcat^^disfordoll^^andeisforelephantfisforfish^^gisforgreen^^hisforhat^^iisforicecreem^^andjisforjarkisforking^^lisforlion^^misformango^^nisfornose^^andoisfororange
最佳答案
正则表达式最适合这种多字符
input.txt
aisforapple^^bisforball^^cisforcat^^disfordoll^^andeisforelephant
fisforfish^^gisforgreen^^hisforhat^^iisforicecreem^^andjisforjar
kisforking^^lisforlion^^misformango^^nisfornose^^andoisfororange
PigScript
A = LOAD 'input.txt' AS line;
B = FOREACH A GENERATE FLATTEN(REGEX_EXTRACT_ALL(line,'(.*)\\^\\^(.*)\\^\\^(.*)\\^\\^(.*)\\^\\^(.*)')) AS (f1,f2,f3,f4,f5);
DUMP B;
Output:
(aisforapple,bisforball,cisforcat,disfordoll,andeisforelephant)
(fisforfish,gisforgreen,hisforhat,iisforicecreem,andjisforjar)
(kisforking,lisforlion,misformango,nisfornose,andoisfororange)
解释:
For better understanding i break the regex into multiple lines
(.*)\\^\\^ ->Any character match till ^^ and stored into f1,(double backslash for special characters)
(.*)\\^\\^ ->Any character match till ^^ and stored into f2,(double backslash for special characters)
(.*)\\^\\^ ->Any character match till ^^ and stored into f3,(double backslash for special characters)
(.*)\\^\\^ ->Any character match till ^^ and stored into f4,(double backslash for special characters)
(.*) ->Any character match till the end of string and stored into f5
关于hadoop - pig 自定义函数加载多个字符 ^^(双胡萝卜)定界符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26535051/
在我们的旧版本中,选择元素上有一个向上/向下的胡萝卜。但是,我检查了元素和 css。没有地方可以定义胡萝卜样式。 我想在我们的新版本中展示胡萝卜。我怎样才能使用 css 做到这一点。 我相信我需要 a
我环顾四周,找不到任何东西可以让我的脚本正确使用特殊字符(例如 ! 或 ; 或 ^) 在文件路径或文件名中。 我的脚本确实有效,但前提是上述字符不在任何扫描的文件夹或文件名中。如果任何文件夹或文件具有
我是一名优秀的程序员,十分优秀!