Quantcast
Channel: Hortonworks » All Replies
Viewing all articles
Browse latest Browse all 3435

SUBSTRING on a fixed length

$
0
0

I have a txt file of fixed length:
ABCDEFGHIJ0000100002
I have the following code:
D = LOAD ‘/user/us059919/testfile2.txt’ USING PigStorage() AS (row:chararray);
E = FOREACH D GENERATE SUBSTRING(row,0,20) as one,
SUBSTRING(row,10,5) as value1,
SUBSTRING(row,15,5) as value2;
DESCRIBE E;
DUMP E;

The output displayed is:
(ABCDEFGHIJ0000100002,,,)
The question is that it’s not parsing the values for “value1″ (position 10 for length 5) and “value2″ (position 15 for length 5) – input file position 1 is PIG posn 0.
Both these are displayed as null.
Could anyone explain why please?
Thanks.
Soyab


Viewing all articles
Browse latest Browse all 3435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>