Saturday, December 29, 2012

Using Perl's -F flag


Below is one example where i have used perl's -F flag:

I have a CSV file that looks a little like this, only a lot bigger:

    550672,1
    656372,1
    766153,1
    550672,2
    656372,2
    868194,2
    766151,2
    550672,3
    868179,3
    868194,3
    550672,4
    766153,4

The values in the first column are a ID numbers and the second column could be described as a property (for want of a better word...).  The ID number 550672 has properties 1,2,3,4.  ideal output would be a new csv file which looks something like:

    550672,1;2;3;4
    656372,1;2
    766153,1;4

No comments:

Post a Comment