Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Need to format text records from a hugh file
@ 1999-06-28  4:00 wli
  1999-06-28  4:00 ` JGM_van_Ras
  0 siblings, 1 reply; 2+ messages in thread
From: wli @ 1999-06-28  4:00 UTC (permalink / raw)


Hi,

I wonder if someone can help me on the following problem.

I have an export file with 4 fields in each record i.e.

AAAAAAA  ; BBBBBBBBB ; C            ; DDD
AAAA         ; BBBBBB          ; CCCCCC    ;   D

and I need to reformat the records by removing the ";"  with the
following condition

1. A field starts from 1st col. to 7th col.
2. B field starts from 8th col. to 34th col.
3. C field starts from 35th col. to 55th col.
4. D field starts from 55th col. to 60th col.

If the text is less that the length of field, space (from space bar)
will be appended to the end of that field.

Is there a simple way that I can do it with "vi" or is there any tools
or script that I can do that?

The file has 200000 records and I just can't afford to change them one
by one and I need it quite urgent.

Thanks in advanced for any help.
William


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Need to format text records from a hugh file
  1999-06-28  4:00 Need to format text records from a hugh file wli
@ 1999-06-28  4:00 ` JGM_van_Ras
  0 siblings, 0 replies; 2+ messages in thread
From: JGM_van_Ras @ 1999-06-28  4:00 UTC (permalink / raw)


With sed and awk command :

    cat inputfile  sed "s/;//g" |awk '{printf("%-8s%-33s%-54s%-59s\n",$1," "$2," "$3," "$4)}' > outputfile

Good luck
*** Philips Medical Systems Netherlands
*** System Dev. Cardio/Vascular
*** Hardware, Librarian & Support Unix
*** The Netherlands
***   mailto:jos@jgmvanras.demon.nl
*** Homepage:http://www.jgmvanras.demon.nl/

wli@cincom.com wrote:

> Hi,
>
> I wonder if someone can help me on the following problem.
>
> I have an export file with 4 fields in each record i.e.
>
> AAAAAAA  ; BBBBBBBBB ; C            ; DDD
> AAAA         ; BBBBBB          ; CCCCCC    ;   D
>
> and I need to reformat the records by removing the ";"  with the
> following condition
>
> 1. A field starts from 1st col. to 7th col.
> 2. B field starts from 8th col. to 34th col.
> 3. C field starts from 35th col. to 55th col.
> 4. D field starts from 55th col. to 60th col.
>
> If the text is less that the length of field, space (from space bar)
> will be appended to the end of that field.
>
> Is there a simple way that I can do it with "vi" or is there any tools
> or script that I can do that?
>
> The file has 200000 records and I just can't afford to change them one
> by one and I need it quite urgent.
>
> Thanks in advanced for any help.
> William
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-06-28  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-06-28  4:00 Need to format text records from a hugh file wli
1999-06-28  4:00 ` JGM_van_Ras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox