我正在分析文件中包含任何分隔符数据的数据文件(CSV,'TSV'\t';') 该方法适用于“,”和“;”,但不适用于制表符“\t”,我们如何将tab作为param传递给pig?在
python代码
delimiter = '\t'
cmd = 'pig -f sample.pig -p file='+data_file +' -p delimiter=' + delimiter
subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT)
猪
^{pr2}$我得到以下例外
2014-03-31 03:26:41,412 [main] INFO org.apache.pig.tools.parameters.ParameterSubstitutionPreprocessor - The parameter: "delimiter= " cannot be parsed by Pig. Please double check it
2014-03-31 03:26:41,412 [main] INFO org.apache.pig.tools.parameters.ParameterSubstitutionPreprocessor - Parser give the follow error message:
2014-03-31 03:26:41,413 [main] INFO org.apache.pig.tools.parameters.ParameterSubstitutionPreprocessor - Encountered "<EOF>" at line 1, column 16.
Was expecting one of:
<IDENTIFIER> ...
<OTHER> ...
<LITERAL> ...
<SHELLCMD> ...
此处不要使用shell;tab是shell的空白,不作为参数发送:
请注意,我将
shell
保留为默认的False
;当您可以直接调用pig
时,不需要将此命令传递给shell。当shell
留在False
时,改为传入一个参数列表。在即使如此,我认为你可能需要给
^{pr2}$pig
序列\t
(两个字符):或使用原始字符串:
如果这不起作用,您将不得不使用特殊的大小写;我只读取pig latin expressions reference,因此这是未经测试的,但是我将使用一个条件表达式和
TAB
作为命令行参数:在Python中:
相关问题 更多 >
编程相关推荐