Delimters in pig or python



0


Problem
============
COVERAGES LIABILITY DEDUCTIBLE RATE PREMIUM
A. Marina,Operators $ 1,000,000 $ 1,000 .18 $ 1,802.
B. Boat Dealer $ $ $
C. Owned $ xxx $
D. Floating  $ xxx $
E. Protection  $ 1,000,000 $ FLAT $ 825.
F. TERR $ $ $ 53.

Using Pig and Python, How do i convert the above probelm into a below shown output (tab delimited )......???

Note :

1. Rate column doesnot start with Dollar. and it can be NULL (not blank)

2.LIABILITY,DEDUCTIBLE and PREMIUM caneither start with $ or any hardcoded value and it can be NULL followed by a dollar (not blank)


REQUIRED OUTPUT (solution)
================
 
COVERAGES                           LIABILITY          DEDUCTIBLE      RATE   PREMIUM
A. Marina,Operators                  $ 1,000,000         $ 1,000                .18         $ 1,802.
B. Boat Dealer                          $                        $                                       $
C. Owned                                 $                        xxx                                   $
D. Floating                               $                        xxx                                    $
E. Protection                           $ 1,000,000         $                           FLAT     $ 825.
F. TERR                                  $                       $                                         $ 53.


3 Answer(s)


0

Hi Sirajuddin,

STORE result INTO 'myoutput' using PigStorage('\t');

Just changing the default delimiter will do the job.

Hope this helps.

Thanks.


0

No, there is no delimiter at all., if u copy paste the problem to a txt file., you will see there is no 'tab'


0

Hi Sirajuddin,

The delimiter like '\n' or '\t' is not visible in the text file. Those are used to define tab and line end in the programming code.

You have to add the delimiter while storing the file not while loading the file. So, you have to add the delimiters.

Hope this helps.

Thanks.

Your Answer

Click on this code-snippet-icon icon to add code snippet.

Upload Files (Maximum image file size - 1.5 MB, other file size - 10 MB, total size - not more than 50 MB)

Email
Password