Computing.Net > Forums > Solaris > script to format data

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

script to format data

Reply to Message Icon

Name: wolf60s
Date: December 19, 2003 at 19:02:58 Pacific
OS: solaris 9
CPU/Ram: P4/256
Comment:

Hi, I have following data format:

A : ABC
Model: v3.5.8
source: C:\data\ABC.raw
B : 123
C : 2000-10-28
D : 05:17
E : 2000-11-08
F : 01:15
name: scott tiger
Purpose: Production
P_id: 213435
Class: Normal
G_id: 1828G
SS (m): 1008W x 859H
SI (m): 16.000
SC (m): 15.000
ST (m): 0.500
NFZ: 4
Vstd: EF098
VC: 0.885
CE: 0.881
Notes: None


G H I J K L(1/m) M(n/m/m) N(n)

XYZ efg 10.04 0.123 N 0.52 0 0
XYZ hijk 123.15 0.456 N 0.24 0 0
XYZ lmn 1001.50 0.789 N 0.88 0 0
XYZ opq 1102.20 0.147 N 0.35 0 0
....


I need to convert above data as following format which will be recognized by oracle sql*loader.

ABC 123 2000-10-28 05:17 2000-11-08 01:15 XYZ efg 10.04 0.123 N 0.52 0 0
ABC 123 2000-10-28 05:17 2000-11-08 01:15 XYZ hijk 123.15 0.456 N 0.24 0 0
ABC 123 2000-10-28 05:17 2000-11-08 01:15 XYZ lmn 1001.50 0.789 N 0.88 0 0
ABC 123 2000-10-28 05:17 2000-11-08 01:15 XYZ opq 1102.20 0.147 N 0.35 0 0
.........

How to write a shell script to do the job? Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: mdhmi
Date: December 28, 2003 at 14:14:38 Pacific
Reply:


Either AWK or PERL will work for this.

Mark


0

Response Number 2
Name: unise_nl
Date: December 31, 2003 at 04:48:16 Pacific
Reply:

#! /usr/bin/perl
open( FD, "< data" ) or die "cannot open data";
foreach ( <FD> ) {
if ( /^A : / ) {
( $val ) = /.*: (.*)$/;
next;
}
if ( /^B : / or /^C : / or /^D : / or /^E : / or /^F : / or /^C : / ) {
( $n_val ) = /.*: (.*)$/;
$val = $val." ".$n_val;
next;
}
if ( /^XYZ/ ) {
print $val." ".$_;
}
}
0;


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


grep file for key in loop... Solaris 8 - linksys DHCP ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Solaris Forum Home


Sponsored links

Ads by Google


Results for: script to format data

checked a script to count the numbe www.computing.net/answers/solaris/checked-a-script-to-count-the-numbe/3894.html

Script to dectect vi /etc/host file www.computing.net/answers/solaris/script-to-dectect-vi-etchost-file/2853.html

shell script to check a dynamic ip www.computing.net/answers/solaris/shell-script-to-check-a-dynamic-ip/4287.html