Advertisement

08.02.2008 at 09:43PM PDT, ID: 23616895
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

multifunction awk- remove characters, delete lines, and conditional change of other field

Asked by derdle in Scripting Languages, Parsers

Tags:

I'm needing to create an awk statement, that performs a few different functions on an input file I have.  I'm open to other suggestions as to how best to accomplish this, I just know awk has the strength to do it...I'm just not that versed, and am having trouble.

The file has three comma delimited fields.  The first field will always remain the same.  The second field  needs to be examined, with a couple different results pending on what is found:

1) If the field is completely non-numeric, the line should be removed from the file.
2) If the field is numeric, and less than seven digits in length, the line should be removed.
3) If field is all numeric and 7 or more digits in length, it remains as is.
3) All non-numeric characters should be removed from the field, with the third field being set as follows when the appropriate characters (upper or lower case) are found and removed  
                H found in field #2, field #3 is set to 1
                D or DA, field3=2
                E, field3=3
                W or WORK, field3=4,
                P, field3=6
                F or FAX, field3=7
                C or CELL, field3=8
                B, field3=9
                Any other non-numeric, field3=11

Here are a few examples of possible input lines and expected output:

51160,non-published,1            line deleted
52143,419-350-1393c,2         52143,4193501393,8
55326,440-442-3266pw,1      55326,4404423266,4
55766,do not use,3                 line deleted
56290,740-464-2169c,1         56290,7404642169,8
56498,859-745-9215w,1        56498,8597459215,4
60044,240-493-7064h,3         60044,2404937064,1
61304,717-285-5827da,1       61304,7172855827,2
67223,(322)955-7266,11       67223,3229557266,11
55598,800.222.8484x203,4   55598,8002228484203,11  

I don't mind making multiple passes on the file if it's needed...

All help is greatly appreciated...  Thanks guys.Start Free Trial
[+][-]08.03.2008 at 04:06PM PDT, ID: 22149203

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.03.2008 at 04:10PM PDT, ID: 22149208

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.03.2008 at 04:20PM PDT, ID: 22149223

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.03.2008 at 07:28PM PDT, ID: 22149603

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.03.2008 at 07:38PM PDT, ID: 22149631

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.03.2008 at 07:44PM PDT, ID: 22149651

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.03.2008 at 07:52PM PDT, ID: 22149671

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.03.2008 at 07:58PM PDT, ID: 22149684

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Scripting Languages, Parsers
Tags: awk scripting
Sign Up Now!
Solution Provided By: dmadole
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.03.2008 at 08:40PM PDT, ID: 22149807

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628