Home

Wednesday, December 24, 2008

Extract data from ascii file to csv format

This is a simple example to demo how to pick-up certain data on many fixed files and put them into csv format. The basic example you can use to do your daily fixed format reports, raw files and log files.


#! /bin/csh

ls grep "_Final" > file.txt
echo "" > outname.csv

foreach file (`cat file.txt`)

set tp = `grep "Test Program" $file head -1 awk '{print $3}'`
set lot = `grep "Lot Id" $file tail -1 awk '{print $3}' tr '[a-z]' '[A-Z]'`
set fail = `grep "Total Fail" $file tail -1 awk '{print $3}'`
set cont = `grep "continuity" $file tail -1 awk '{print $4}'`
set Vcore = `grep "Vcore" $file tail -1 awk '{print $4}'`
set Vddr = `grep "Vddr" $file tail -1 awk '{print $4}'`
set Vsmb = `grep "Vsmb" $file tail -1 awk '{print $4}'`
set date1 = `grep "Lot Started at" $file head -1 awk '{print $4}'`
echo "$date1,$lot,$tp,$fail,$cont,$Vcore,$Vddr,$Vsmb" >> outname.csv

end

No comments:

Post a Comment