Grep and substitute?
I have to parse ASCII files, output the relevant data to a comma-delimited file and load it into a database table.
The specs for the file format have been recently updated and one section is causing problems. This is the original layout for that section. Code:
CSVHeaderAttr:PUIS,IdleImmediate,POH,Temp,WorstTemp Code:
CSVAttributes=$(grep ^CSVValuesAttr: ${filename}|cut -d':' -f2) Code:
CSVHeaderAttr:PUIS,IdleImmediateSupported,IdleImmediateEnabled,POH,Temp,WorstTemp Is there a way to use grep to produce an output like this and substitute empty fields with NA? For one file type: Code:
CSVHeaderAttr:PUIS,IdleImmediate,IdleImmediateSupported,IdleImmediateEnabled,POH,Temp,WorstTemp Code:
CSVHeaderAttr:PUIS,IdleImmediate,IdleImmediateSupported,IdleImmediateEnabled,POH,Temp,WorstTemp |
You showed understanding of it here (https://www.linuxquestions.org/quest...values-912724/) so why not use awk to test fields for length == 0 and subst "NA"?
|
All times are GMT -5. The time now is 10:14 PM. |