Hello,
Sorry I am very new to perl. I looked around on the web. Would really appreciate your help. I am looking for a perl program which could handle following reqirement. Requirement: We have a pipe delimited text data file called Product_Models.txt First row of this file is headers. The rows following that will have actual data values for it. So the file Product_Models.txt will look like this: (I have kept only relevent columns here for simplicity)
ModelName|Color
model_1|Red
model_2|Blue
model_2|Green
model_2|Yellow
model_3|White
model_3|Black
model_4|Red
All I want the program to do is create a New file, which will have the only the Unique ModelName and it's Count. Column saperator will be pipe.
So for above input file, this program should create a new file called: ModelCountOutput.txt and it's content will have one header row, followed by it's values looking like this:
ModelName|Count
model_1|1
model_2|3
model_3|2
model_4|1
Thank you so much for your help!!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.