Extract fields from records with complicated structure

Extract fields from records with complicated structure

Post by Peifong R » Mon, 23 Sep 1996 04:00:00



Hi,

I would like to come up an efficient way to extract certain fields
from a binary record:

This record has 700 possible layouts, each layout has a structure code.
The record's average size is 130 bytes.
Each record can have different number of fields, it is decided by its
layout.

Also, some layouts are decided by a nested if-else-then rules.

Does anyone have any similar experience to deal with this records?

How to make the lookup part of extraction efficient?

Any help or pointer will be appreciated!

Thanks,
-Pei

 
 
 

Extract fields from records with complicated structure

Post by Peifong R » Mon, 23 Sep 1996 04:00:00


Reposting article removed by rogue canceller.

Hi,

I would like to come up an efficient way to extract certain fields
from a binary record:

This record has 700 possible layouts, each layout has a structure code.
The record's average size is 130 bytes.
Each record can have different number of fields, it is decided by its
layout.

Also, some layouts are decided by a nested if-else-then rules.

Does anyone have any similar experience to deal with this records?

How to make the lookup part of extraction efficient?

Any help or pointer will be appreciated!

Thanks,
-Pei


 
 
 

Extract fields from records with complicated structure

Post by Dann Corbi » Wed, 25 Sep 1996 04:00:00


This sort of layout comes from the 'old days'
before relational database technology.  In
Pascal, you used to use a variant record, in C
it was a union, in COBOL redefines, in FORTRAN
named common.
For the nested rules, use a union in a union
( or whatever is appropriate ).
Data alignment can be a problem in record
definitions like this, so be carful of how
the data is packed and unpacked.
HTH
--
"I speak for myself and all of the lawyers of the world"
If I say something dumb, then they will have to sue themselves.



> Reposting article removed by rogue canceller.

> Hi,

> I would like to come up an efficient way to extract certain fields
> from a binary record:

> This record has 700 possible layouts, each layout has a structure code.
> The record's average size is 130 bytes.
> Each record can have different number of fields, it is decided by its
> layout.

> Also, some layouts are decided by a nested if-else-then rules.

> Does anyone have any similar experience to deal with this records?

> How to make the lookup part of extraction efficient?

> Any help or pointer will be appreciated!

> Thanks,
> -Pei


 
 
 

1. How do I extract a field between two other fields?

given a file like so:
 VG Name                /dev/vg03
   PV Name                /dev/dsk/c0d0s2
VG Name                /dev/vg01
   PV Name                /dev/dsk/c1d0s2
VG Name                /dev/vg00
   PV Name                /dev/dsk/c2d0s2
VG Name                /dev/vg02
   PV Name                /dev/dsk/c3d0s2
VG Name                /dev/vg07
   PV Name                /dev/dsk/c6d0s2
VG Name                /dev/vg05
   PV Name                /dev/dsk/c7d0s2
VG Name                /dev/vg06
   PV Name                /dev/dsk/c8d0s2
VG Name                /dev/vg04
   PV Name                /dev/dsk/c9d0s2

I need to extract the PV field(s) between the VG Name field(not including
the VG Name field) as there could be more than one PV Name field per volume
group.

I am not sure of how to do this, I am assuming that grep,awk, or sed is
involved Would anyone be as so kind as to provide me with a snippet of code
that may produce the output that I want?
Any help would be greatly appreciated!!

2. Installation RH6.0 on a SCSI drive NOT supported by RH6.0

3. Fixed length records containing 2 different records types with fixed field widths

4. Determining a process' own name

5. awk - extracting field between "'"

6. Problems with colours in CDE with certain applications

7. Newbie - extracting fields in ksh

8. GCC and Structure field alignment

9. How to extract second field in ps command output?

10. Extracting date fields using sed and awk

11. questions on field in pci_dev structure

12. sed: extracting single field from each line of a CSV file