2015-08-18 373 views
-1

這是我的數據:阿帕奇豬CsvExcelStorage

"2001-08-10 01:09:29","3820166553","<P><TABLE border=0 cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD style="BACKGROUND-COLOR: #eee"> 
<TABLE border=0 cellSpacing=0 cellPadding=0 align=center><TBODY><TR><TD style="BACKGROUND-COLOR: #fff" class=maincontent><TABLE style="MARGIN: 0px auto" border=0 cellSpacing=0 cellPadding=0 width=580 align=center><TBODY><TR><TD colSpan=2><A href="general/forms/YHMN?ci=0c01026bd7fbc394&amp;ags=D778083&amp;cn=KOBY&amp;pfnn="><IMG border=0 alt="Thanks for contacting us click here button" src="http:/edm/tcp-images/yhan-edm-banner-purple_button.jpg" width=580 height=255></A></TD></TR><TR><TD style="PADDING-BOTTOM: 35px; PADDING-LEFT: 32px; PADDING-RIGHT: 32px; PADDING-TOP: 35px" colSpan=2><P style="TEXT-ALIGN: left; LINE-HEIGHT: 18px; MARGIN-TOP: 0px; FONT-FAMILY: Arial, Helvetica, sans-serif; COLOR: #414141; FONT-SIZE: 14px" align=left></P><P style="TEXT-ALIGN: left; LINE-HEIGHT: 18px; FONT-FAMILY: Arial, Helvetica, sans-serif; COLOR: #414141; FONT-SIZE: 14px" align=left>If...",,"778083" 

豬腳本:

stage = LOAD '/filename' USING org.apache.pig.piggybank.storage.CSVExcelStorage(',','YES_MULTILINE','UNIX','READ_INPUT_HEADER') as (col1,col2,col3,col4,col5); 
col3_data=FOREACH stage GENERATE col3; 
DUMP col3_data; 

輸出:

(<P><TABLE border=0 cellSpacing=0 cellPadding=0 width=100%"><TBODY><TR><TD style=BACKGROUND-COLOR: #eee"> 
<TABLE border=0 cellSpacing=0 cellPadding=0 align=center><TBODY><TR><TD style=BACKGROUND-COLOR: #fff" class=maincontent><TABLE style=MARGIN: 0px auto" border=0 cellSpacing=0 cellPadding=0 width=580 align=center><TBODY><TR><TD colSpan=2><A href=general/forms/YHMN?ci=0c01026bd7fbc394&amp;ags=D778083&amp;cn=KOBY&amp;pfnn="><IMG border=0 alt=Thanks for contacting us click here button" src=http:/edm/tcp-images/yhan-edm-banner-purple_button.jpg" width=580 height=255></A></TD></TR><TR><TD style=PADDING-BOTTOM: 35px; PADDING-LEFT: 32px; PADDING-RIGHT: 32px; PADDING-TOP: 35px" colSpan=2><P style=TEXT-ALIGN: left; LINE-HEIGHT: 18px; MARGIN-TOP: 0px; FONT-FAMILY: Arial) 

我使用csvExcelStorage加載我的數據文件在豬裏。文件中的一列有行尾字符。數據文件看起來像

"2015-08-17 23:55:59","12345","<P>this is test data, 
<TR> 
<\TR><BODY>Text-Align: Arial, Roman,feed this; end of input...","column 4" 

負荷聲明如下:

stage=LOAD '/data/file' using csvExcelStorage(',','YES_MULTILINE','NOCHANGE','READ_INPUT_HEADER') as (col1,col2,col3,col4) 

當我傾倒數據加載之後我收到以下

col3 = <P>this is test data, 
<TR> 
<\TR><BODY>"Text-Align: Arial 

col4 = Roman 

因此col3包含不完整的數據,而col4有錯誤的數據。

請幫助確定這裏有什麼問題。

+0

豬哪個版本的?你可以將階段別名的DUMP結果添加到問題中嗎? –

回答

0

試過上面的用例,只做了修改就是引用CSVExcelStorage.Its獲取field3的期望值。

我相信你已經定義了一個別名爲csvExcelStorage來參考。這個班。

豬版本:Apache Pig版本0.14.0(r1640057)2014年11月16日18:01:24編譯。

輸入:

"2015-08-17 23:55:59","12345","<P>this is test data, 
<TR> 
<\TR><BODY>Text-Align: Arial, Roman,feed this; end of input...","column 4" 

豬腳本:

csvexceldata = LOAD 'csvdata.csv' USING org.apache.pig.piggybank.storage.CSVExcelStorage(',','YES_MULTILINE','NOCHANGE','READ_INPUT_HEADER') AS (col1,col2,col3,col4); 
col3_data = FOREACH csvexceldata GENERATE col3; 
DUMP col3_data; 

輸出:

(<P>this is test data, 
<TR> 
<\TR><BODY>Text-Align: Arial, Roman,feed this; end of input...)