1

I'm beginning learn PIG and I want to split a tuple in character '\'. My original tuple is

(192.168.2.227\al0000)

and I need to split it in '\'

(192.168.2.227, al0000)

I tryed to use

B =  FOREACH original GENERATE FLATTEN (STRSPLIT(tuple, '\\u034B'));

but it dont work. What is the proper solution ?

2 Answers2

2

Input :

192.168.2.227\al0000

Pig Script :

A = LOAD 'input.csv' as line;  
B = FOREACH A GENERATE FLATTEN (STRSPLIT(line, '([\\\\])'));
dump B; 

Second argument used is a regex to identify '\'

Output :

(192.168.2.227,al0000)

Ref :

  1. http://pig.apache.org/docs/r0.14.0/func.html#strsplit
  2. Can't escape the backslash with regex?
Community
  • 1
  • 1
Murali Rao
  • 2,287
  • 11
  • 18
0

Did you try '\\\\' in place of the strange unicode code point u034B?