Need help on filtering


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help on filtering
# 1  
Old 08-02-2013
Need help on filtering

Hi experts,

I have a file image.csv as below:

Code:
COMPUTERNAME,23/07/2013,22/07/2013,21/07/2013,20/07/2013,19/07/2013,18/07/2013,17/07/2013 
AED03852180,3,3,3,3,3,3,3 
AED03852181,3,3,3,3,3,3,1 
AED09020382,3,0,3,0,3,3,3 
AED09020383,1,3,3,3,2,1,3 
AED09020386,3,3,0,3,3,0,3 
AED09020979,3,3,3,3,3,3,3 
AED09020981,3,3,0,0,3,3,3 
AED09202354,3,2,3,0,3,3,3 
AED09504679,3,3,3,3,0,0,0

We are getting 0 values for different dates. i need to get the report of the 0 values as below:
output.csv
===========
Code:
COMPUTERNAME,DATE
AED09020382,22/07/2013
AED09020382,20/07/2013
AED09020386,21/07/2013
AED09020386,18/07/2013
AED09020981,21/07/2013
AED09020981,20/07/2013
AED09202354,20/07/2013
AED09504679,19/07/2013
AED09504679,18/07/2013
AED09504679,17/07/2013

Please help !!!

Thanks

Last edited by radoulov; 08-02-2013 at 07:39 AM..
# 2  
Old 08-02-2013
Try:
Code:
awk -F, 'NR==1{for(i=2;i<=NF;i++) d[i]=$i;print "COMPUTERNAME,DATE"}NR>1{for (i=2;i<=NF;i++) if ($i==0) print $1","d[i]}' image.csv > output.csv

# 3  
Old 08-02-2013
Not Working... Smilie

Code:
$> awk -F, 'NR==1{for(i=2;i<=NF;i++) d[i]=$i;print "COMPUTERNAME,DATE"}NR>1{for (i=2;i<=NF;i++) if ($i==0) print $1","d[i]}' /tmp/image.csv 
COMPUTERNAME,DATE
$>

# 4  
Old 08-02-2013
Code:
perl -F',' -lane 'BEGIN {print "COMPUTERNAME,DATE"};if($. eq 1){@hdr=@F;next}; for($i=0;$i<@F;$i++){ ($F[$i] eq 0) &&  print "$F[0],$hdr[$i]"}' file

# 5  
Old 08-02-2013
What operating system are you using? Also post output of:
Code:
cat -ev /tmp/image.csv | head

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filtering out rows

# powermt display dev=all .... snipped ... Pseudo name=hdiskpower8 Symmetrix ID=000192602584 Logical device ID=059F state=alive; policy=SymmOpt; priority=0; queued-IOs=0 ============================================================================== ---------------- Host --------------- ... (7 Replies)
Discussion started by: Daniel Gate
7 Replies

2. UNIX for Dummies Questions & Answers

filtering out certain output

hi guys, i have a long output and cant figure out a flexible way to show the meta members from a device. please help. some device have 2,4 or 8 meta members but for this example i have 4 meta members, what is a flexible way to pull them out from this output? need your inputs thanks. ... (4 Replies)
Discussion started by: prodigy06
4 Replies

3. Shell Programming and Scripting

text filtering

INPUT FILE: Date: 10-JUN-12 12:00:00 B 0: 00 00 00 00 10 00 16 28 B 120: 00 00 00 39 53 32 86 29 Date: 10-JUN-12 12:00:10 B 0: 00 00 00 00 10 01 11 22 B 120: 00 00 00 29 23 32 16 29 Date: 10-JUN-12 12:00:20 B 0: 00 00 00 00 10 02 17 29 B 120: 00 00 35 51 42 66 14 Date: 10-JUN-12... (5 Replies)
Discussion started by: thibodc
5 Replies

4. UNIX for Dummies Questions & Answers

Filtering the duplicates

Hello, I want to filter all the duplicates of a record to one place. Sample input and output will give you better idea. I am new to unix. Can some one help me on this? Input: 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr1.fa chr1.fa... (2 Replies)
Discussion started by: koneru_18
2 Replies

5. Shell Programming and Scripting

Filtering

Hi I am interested in DNS resolving a set of sites and each time the output is different- $ host www.yahoo.com www.yahoo.com is an alias for fd-fp3.wg1.b.yahoo.com. fd-fp3.wg1.b.yahoo.com is an alias for ds-fp3.wg1.b.yahoo.com. ds-fp3.wg1.b.yahoo.com is an alias for... (1 Reply)
Discussion started by: jamie_123
1 Replies

6. AIX

Need help with filtering

Hi!! I have a bit of a task here and filtering/scripting not my strongest. I have to collect info of approx 1100 hdiskpower.so i have appended all the hdisk into a text file and i need it to run the command lscfg -vl to confirm if the drive is symmetrix. here's what i have so far at... (3 Replies)
Discussion started by: vpundit
3 Replies

7. Shell Programming and Scripting

filtering with awk

i have question about awk ex: input.txt 1252468812,yahoo,3.5 1252468812,hotmail,2.4 1252468819,yahoo,1.2 msn,1252468812,8.9 1252468923,gmail,12 live,1252468812,3.4 yahoo,1252468812,9.0 1252468929,msn,1.2 output.txt 1252468812,yahoo,3.5 1252468812,hotmail,2.4 msn,1252468812,8.9... (3 Replies)
Discussion started by: zvtral
3 Replies

8. Shell Programming and Scripting

Please help me to do some filtering

I have to grep a pattern. scenario is like :- Suppose "/etc/sec/one" is a string, i need to check if this string contains "one" using any utility something like if /etc/sec/one | grep ; then Thanks in advance Renjesh Raju (3 Replies)
Discussion started by: Renjesh
3 Replies

9. Shell Programming and Scripting

filtering the logs

Hi, We are using rsync for syncing remote directories. It is working great along with detailed logs. As the script cron'd and most of the times there're no files to sync we are getting lot of unnecessary log entries and we need to filter them to show only the log entries for the files... (5 Replies)
Discussion started by: prvnrk
5 Replies

10. HP-UX

port filtering

hi All I have to do port filtering on Unix servers.But unfortunately ip filter is not installed on the server.Now i am thinking of stopping the services.Can anybody tell me how do i go about it?Somebody told me about etc/services option?But that does not look a viable option.I think that is only... (0 Replies)
Discussion started by: ujjwalmohan
0 Replies
Login or Register to Ask a Question