Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: reformatting tab delimited file

by davido (Archbishop)
on Sep 05, 2011 at 15:00 UTC ( #924258=note: print w/ replies, xml ) Need Help??


in reply to reformatting tab delimited file

Create a hash such as %categories. Iterate over the lines of your list. For each line, split on whitespace, then push @{$categories{$second_column}}, $third_column;

I'm assuming you know how to open a file and read from it. A while loop will be helpful in iterating over each line. Don't forget to chomp.

Output should just be a matter of obtaining the lists held under each hash key and printing them side by side. Another loop with some logic to print a placeholder instead of an item for a given column when one column runs out of entries while others still have entries.


Dave


Comment on Re: reformatting tab delimited file
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://924258]
help
Chatterbox?
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: (6)
As of 2015-07-04 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls