Script to get the heading in files along with data | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Script to get the heading in files along with data

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-04-2013
Vivekit82 Vivekit82 is offline
Registered User
 
Join Date: Aug 2013
Last Activity: 28 March 2014, 4:24 PM EDT
Posts: 62
Thanks: 2
Thanked 0 Times in 0 Posts
Script to get the heading in files along with data

Hi everyone,

I have a file which has data with different heading and column names as below.


Code:
Static Data Ingested
,,,,,,,,,,,,Known Explained Rejections
Column_1,column_2,Column_3,Column_4,,Column_6,Column_7,,% Column_8,,Column_9 ,Column_10
viv,Public_456,08/28/2013,1234566,,08/31/2013,5896325,,0.00,,0,0
SDS,Public_ddd,08/28/2013,589652,,08/31/2013,2365896,,0.00,,0,1

In the above few are null columns and Static Data Ingested is the heading of therecords at line 1.At line 2 is ,,,,,,,,,,,,Known Explained Rejections and at line 3 and 4 are the column names and the records.

After few lines say line 20 start the second heading and the records as below:


Code:
Static Data extracted
Column_1,Column_2,Column_3,Column_4,Column 5,Column_6,Column 7
rms,k2c,5896325,0.00,,0,1
SDS,k3c,2365896,0.00,,0,0

Now i want to get the data from the above records only if Column 9 and 10 in first heading(Static Data Ingested) and column column 6 and 7 in second heading(Static Data extracted) have records other than 0.

For the above input output should be as below.


Code:
 
Static Data Ingested:
Column_1,column_2,Column_3,Column_4,,Column_6,Column_7,,% Column_8,,Column_9 ,Column_10
SDS,Public_ddd,08/28/2013,589652,,08/31/2013,2365896,,0.00,,0,1

Static Data extracted:
Column_1,Column_2,Column_3,Column_4,Column 5,Column_6,Column 7
rms,k2c,5896325,0.00,,0,1

Sponsored Links
    #2  
Old 09-04-2013
Jotne's Avatar
Jotne Jotne is offline
Registered User
 
Join Date: Dec 2010
Last Activity: 25 July 2014, 9:30 AM EDT
Posts: 1,038
Thanks: 62
Thanked 216 Times in 204 Posts
What is wrong with this post:
http://www.unix.com/shell-programmin...-csv-file.html
The Following User Says Thank You to Jotne For This Useful Post:
vbe (09-04-2013)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sqlplus Set Heading not Working flowervz Shell Programming and Scripting 2 11-26-2012 09:40 AM
Extract columns from multiple files with a file name as heading Unilearn UNIX for Dummies Questions & Answers 1 08-24-2011 05:49 AM
SQL sorrting issue, and unwanted blank line above heading dazz Shell Programming and Scripting 1 04-12-2010 04:08 AM
Help - Bug: A script to compile two types of data files into two temporary files ilove2smoke Shell Programming and Scripting 3 12-21-2009 09:34 AM
What is the command to add heading to a file? whatisthis UNIX for Dummies Questions & Answers 3 12-02-2005 02:17 AM



All times are GMT -4. The time now is 02:50 PM.