Can you check if this works for you?
- It will work with all input files with different delimiters.
- It will work with the same file with a different delimiter.
You can add as many delimiters within a character class. [,:,]
Example:
input1.txt
1,2,3,4
input2.txt
a-b-c-d
input3.txt
100:200:300:400
input4.txt
100,aaa-200:b
PigScript:
A = LOAD 'input*' AS line;
B = FOREACH A GENERATE FLATTEN(REGEX_EXTRACT_ALL(line,'(.*)[,:-](.*)[,:-](.*)[,:-](.*)')) AS (f1,f2,f3,f4);
DUMP B;
Output:
(1,2,3,4)
(a,b,c,d)
(100,200,300,400)
(100,aaa,200,b)
source
share