Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Get unique fields from file

by hippo (Bishop)
on Jan 06, 2022 at 09:49 UTC ( #11140214=note: print w/replies, xml ) Need Help??

in reply to Get unique fields from file

Now how to get the unique value for each field and produce an output file. I had this piece of code used somewhere but I hardly can understand it

It depends largely on what you mean by "get the unique value". If your set is (x, x, y) do you want the result to be (y) as that is the only value which is unique or do you want it to be (x, y) as that is all the values but just one occurrence of each? If the latter then then snippet which you have will suffice. Removing duplicates is explained in the FAQ How can I remove duplicate elements from a list or array?.

BTW, since what you have is really an xSV file with pipe delimiters I would strongly suggest you have a look at Text::CSV_XS before rolling your own parser.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11140214]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-05-20 06:58 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (72 votes). Check out past polls.