Problem formatting files 
Author Message
 Problem formatting files

Hello,

    I am trying to formatting an error file into colums for introduce it
in an Excel page. The problem that I have, is that Awk process files by
lines, and the processing that I have to do, it's different for
different lines.
    Can anyone help me with this.

    Thank you.

    Carlos



Mon, 08 Jul 2002 03:00:00 GMT  
 Problem formatting files
Provide a sample of lines in the error file along with
where you want their pieces to be placed in Excel. Without
specifics, the best advice I can offer is to just import
the file(s) into Excel using Excel's text import wizard.

* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful



Mon, 08 Jul 2002 03:00:00 GMT  
 Problem formatting files


Quote:
>Hello,

>    I am trying to formatting an error file into colums for introduce it
>in an Excel page. The problem that I have, is that Awk process files by
>lines, and the processing that I have to do, it's different for
>different lines.
>    Can anyone help me with this.

awk can do different processing for fifferent lines that match
different unique patterns, or one can set up an if then else structure
in awk to do different processing for different line types.

If you need more info, post a simple example stating sample input
and desired output.

Oh, and read the man page.

man awk

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Mon, 08 Jul 2002 03:00:00 GMT  
 Problem formatting files
Quote:
> Thanks for your answer and sorry.

> My input is a file like this:

> -----------------------------
> ----------------------------------------------------------------
> 17/01/00 19:53:00 Datos averia
> Se ha producido un corte en la linea 12345>0>11345
> --------------------------------------------------
> -------------------------------------------
> 17/01/00 19:56:00 Datos corte
> Linea sin datos 13455>0>11234
> -----------------------------
> ----------------------------------------------------------------

> and my output file must be like this:

> 17/01/00;19:53:00;Datos averia;Se ha producido un corte en
> lalinea;12345>0>11345
> 17/01/00;19:56:00;Datos corte;Linea sin datos;13455>0>11234

> Thanks in advance:

> Carlos Ceamanos



Tue, 09 Jul 2002 03:00:00 GMT  
 Problem formatting files


Quote:
> > My input is a file like this:

> > -----------------------------
> > ----------------------------------------------------------------
> > 17/01/00 19:53:00 Datos averia
> > Se ha producido un corte en la linea 12345>0>11345
> > --------------------------------------------------
> > -------------------------------------------
> > 17/01/00 19:56:00 Datos corte
> > Linea sin datos 13455>0>11234
> > -----------------------------
> > ----------------------------------------------------------------

> > and my output file must be like this:

> > 17/01/00;19:53:00;Datos averia;Se ha producido un corte en
> > lalinea;12345>0>11345
> > 17/01/00;19:56:00;Datos corte;Linea sin datos;13455>0>11234

This is a very crude go at it:

#!/usr/bin/awk -f
/^-+$/ {
  if ((getline L1) > 0)
    if ((getline L2) > 0) {
      sub(/ /, ";", L1)
      sub(/ /, ";", L1)
      sub(/[0-9]+>[0-9]+>[0-9]+$/, ";&", L2)
      sub(/ ;/, ";", L2)
      print L1 ";" L2
    }

Quote:
}

/Peter
--
-= Spam safe(?) e-mail address: pez68 at netscape.net =-

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 09 Jul 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Problems with ASCII format text files

2. problem with file format

3. Format of an ASCII file and comp-3 format

4. problem with reading ascii/formatted file

5. Problem with ASCII form of the PPM graphic file format in tcl

6. Strange file behavior with topspeed file format

7. IMAQ Vision - Writing Image Files: File Format

8. Importing Word format file to text file

9. indexed file format and data files- for cobol compilers

10. APL2/PC; ATF-file format

11. 3D mesh file format?

12. need help in parsing a file with wierd format

 

 
Powered by phpBB® Forum Software