Parsing problem

From: Larry Sandwick (lgs_at_sarreid.com)
Date: 12/11/03


To: <beginners@perl.org>
Date: Thu, 11 Dec 2003 15:27:17 -0500

With the little amount of Perl that I know, I have come to a dilemma. I
do not know how to parse this file so in column 1 (24165) is the number
duplicate for every item number in the list. I also need in the 2
column (O185850) to duplicate itself for every item. The 3rd item
(05/30/03)needs to follow the same process. The file format is below,
before the parser.

I know I can split the file on "|" but because the data is not
consistent and my skill set is limiting me to re-parse this file into a
file I can upload into MySql I am asking for help and suggestions I do I
detect that column 1 has change ? Some how I need to read in the first
three lines for every backorder, before I can start outputting the data?
.

This is the file before ( see below what is should look like after the
parser. (Before)

 

24165| DEF | | | | |

     |O18580 |259 |LEATHER BOOK SIDE TABLE | 1| 1| 295.00

     |05/30/03|1774 |FUNCTIONAL TABLE LAMP | 1| 0| 35.00

     | |1773 |FUNCTIONAL FLOOR LAMP | 1| 0| 62.50

     | |1302 |MOROCCAN FLORAL BX,BRASS | 1| 0| 29.00

     | |1666 |CUBA COFFEE TABLE | 1| 1| 290.00

     | |1666 |CUBA SIDE TABLE | 1| 1| 147.50

24310| ABC | | | | |

     |O18813 |1145 |FLEUR-DE-LIS DOCUMENT BOX | 1| 0| 52.50

     |07/29/03|1549 |TAOS CENTERPIECE | 1| 1| 65.00

     | |1729L |FRENCH BOX BOOKEND, LEFT | 1| 1| 69.00

     | |1729R |FRENCH BOX BOOKEND, RIGHT | 1| 1| 69.00

     | |1549 |WINDEMERE BOOK CADDY | 1| 0| 85.00

     | |1774 |REVOLVING BOOK TABLE | 1| 1| 234.00

     | |1574 |NORMANDY 3 DRAWER CONSOLE | 1| 1| 330.00

     | |1765 |LEATHER BOOKS,ASST.SET/12 | 1| 1| 175.00

5522 | XYZ | | | | |

     |O18549 |1551 |HEX LEATHER GARDEN STOOL | 1| 0| 130.50

     |05/20/03|1749 |TRIVET STAND | 1| 1| 87.75

     | |1801 |DESK BOX, VICTORIA | 1| 1| 85.50

     | |1549 |TAOS CENTERPIECE | 1| 1| 58.50

 

(After)

 

Format user | itemkey | date | item | description | order | backorder |
cost

 

24165|O18580|05/30/03|259 |LEATHER BOOK SIDE TABLE | 1| 1|
295.00

24165|O18580|05/30/03|1774 |FUNCTIONAL TABLE LAMP | 1| 0|
35.00

24165|O18580|05/30/03|1773 |FUNCTIONAL FLOOR LAMP | 1| 0|
62.50

24165|O18580|05/30/03|1302 |MOROCCAN FLORAL BX,BRASS | 1| 0|
29.00

24165|O18580|05/30/03|1666 |CUBA COFFEE TABLE | 1| 1|
290.00

24165|O18580|05/30/03|1666 |CUBA SIDE TABLE | 1| 1|
147.50

24310|O18813|07/29/03|1145 |FLEUR-DE-LIS DOCUMENT BOX | 1| 0|
52.50

24310|O18813|07/29/03|1549 |TAOS CENTERPIECE | 1| 1|
65.00

24310|O18813|07/29/03|1729L |FRENCH BOX BOOKEND, LEFT | 1| 1|
69.00

24310|O18813|07/29/03|1729R |FRENCH BOX BOOKEND, RIGHT | 1| 1|
69.00

24310|O18813|07/29/03|1549 |WINDEMERE BOOK CADDY | 1| 0|
85.00

24310|O18813|07/29/03|1774 |REVOLVING BOOK TABLE | 1| 1|
234.00

24310|O18813|07/29/03|1574 |NORMANDY 3 DRAWER CONSOLE | 1| 1|
330.00

24310|O18813|07/29/03|1765 |LEATHER BOOKS,ASST.SET/12 | 1| 1|
175.00

5522 |O18549|05/20/03|1551 |HEX LEATHER GARDEN STOOL | 1| 0|
130.50

5522 |O18549|05/20/03|1801 |DESK BOX, VICTORIA | 1| 1|
85.50

 

Any suggestions would greatly be appreciated !!!

 

TIA

 

Larry Sandwick

Sarreid, Ltd.

Network/System Administrator

phone: (252) 291-1414 x223

fax : (252) 237-1592

 



Relevant Pages

  • Re: Parsing problem
    ... > With the little amount of Perl that I know, I have come to a dilemma. ... > duplicate for every item number in the list. ... > before the parser. ...
    (perl.beginners)
  • Re: kanjidic parser in Perl?
    ... perl. ... Doesn't parse all the fields in the dictionary yet, ... what advanced features you need from a kanjidic parser? ...
    (sci.lang.japan)
  • Re: kanjidic parser in Perl?
    ... perl. ... Maybe you can use the module Lingua::JP::Kanjidic by Simon Cozens? ... Doesn't parse all the fields in the dictionary yet, ... what advanced features you need from a kanjidic parser? ...
    (sci.lang.japan)
  • Re: perl pattern matching
    ... I could be wrong, but I think the OP wants to parse C with Perl, not ... duplicate C in Perl. ...
    (comp.lang.perl.misc)
  • Re: corrupted pointer when initing a dll
    ... then call parser to parse the a2l file and load all the channel ... return result of the load and parse. ... class is housed in a DLL and that DLL can be unloaded while your ...
    (microsoft.public.vc.language)

Loading