복붙노트

[HADOOP] 돼지 - 제거 줄 바꿈, 반환 및 탭

HADOOP

돼지 - 제거 줄 바꿈, 반환 및 탭

나는 문자를 제거하기 위해 노력하고있어 : 돼지의 열에서 \ n을 \의 t와 \의 연구를하지만 잘못된 출력을 얻고있다.

여기에 내가 뭘하는지 있습니다 :

qr_1 = LOAD 'hdfs://localhost:9000/sample.csv' USING PigStorage(',') as (Id:int,PostTypeId:int,AcceptedAnswerId:int,ParentId:int,CreationDate:chararray,DeletionDate:chararray,Score:int,ViewCount:int,Body:chararray,OwnerUserId:int,OwnerDisplayName:chararray,LastEditorUserId:int,LastEditorDisplayName:chararray,LastEditDate:chararray,LastActivityDate:chararray,Title:chararray,Tags:chararray,AnswerCount:int,CommentCount:int,FavoriteCount:int,ClosedDate:chararray,CommunityOwnedDate:chararray);
qr_1 = FOREACH qr_1 GENERATE Id .. ViewCount, REPLACE(Body,'\n','') as Body, OwnerUserId .. ;
qr_1 = FOREACH qr_1 GENERATE Id .. ViewCount, REPLACE(Body,'\r','') as Body, OwnerUserId .. ;   
qr_1 = FOREACH qr_1 GENERATE Id .. ViewCount, REPLACE(Body,'\t','') as Body, OwnerUserId .. ;   

입력:

5585779,1,5585800,,2011-04-07 18:27:54,,1432,3090250,"<p>How can I convert a <code>String</code> to an <code>int</code> in Java?</p>

<p>My String contains only numbers and I want to return the number it represents.</p>

<p>For example, given the string <code>""""1234""""</code> the result should be the number <code>1234</code>.</p>",537967,,2756409,user166390,2015-09-10 21:30:42,2016-03-07 00:42:49,Converting String to Int in Java?,<java><string><type-conversion>,12,0,239

산출:

(5585779,1,5585800,,2011-04-07 18:27:54,,1432,3090250,"<p>How can I convert a <code>String</code> to an <code>int</code> in Java?</p>,,,,,,,,,,,,,)
(,,,,,,,,,,,,,,,,,,,,,)
(,,,,,,,,,,,,,,,,,,,,)
(,,,,,,,,,,,,,,,,,,,,,)
(,,537967,,2756409,user166390,,,Converting String to Int in Java?,,12,0,239,,,,,,,,,)

내가 무엇을하고 있니?

감사.

또한 "\\ n"은 차이를 만들지 않습니다.

해결법

  1. ==============================

    1.이 쉼표는 데이터에 있으며 필드와 스키마가없는 matching.Use CSVLoader 된 후 '\\ t을'대체 REPLACE 명령을 사용하는 이유는,의 '\\ n'을, '\\ R'

    이 쉼표는 데이터에 있으며 필드와 스키마가없는 matching.Use CSVLoader 된 후 '\\ t을'대체 REPLACE 명령을 사용하는 이유는,의 '\\ n'을, '\\ R'

    <p>For example, given the string
    
  2. from https://stackoverflow.com/questions/36212024/pig-remove-line-feed-return-and-tab by cc-by-sa and MIT license