Re: parsing tricky text file

From: Date: Tue, 28 Jan 2003 10:00:42 +0000
Subject: Re: parsing tricky text file
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-18129@lists.php.net to get a copy of this message
What I would do in this case is writing my own little parser program to spool it in to a MySQL database. I often use Delphi for this. What is the record delimiter? OTOP with nothing behind it means emty field? Execept for the USAU fields it seem all very fieldname/content like. Jochem George Pitcher wrote:
Hi, I'm looking for some advice. One of my suppliers (big publisher) has sent me a file containing records of their books. The file is anabsolute nightmare. There are approx 8000 records and the format is like this (actual record): -T&F eBook data rec.1534 @ 27/01/2003 VISBN 0203445570 OSBN 0-203-44557-0 EBK1 0203548310 EBK2 0203651057 EBK3 020375381X EBK4 0203273567 OTOP OTART OTI Creative Mathematics OSUB USAU Upitis |f Rena |u Queens University |c Kingston, Ontario |x
      Canada
USAU Phillips |f Eileen |u Teacher |c Vancover |x Canada USAU Higginson |f William |u Queens University |c Kingston |x
      Canada
EDIT INTRO FORWD Pimm |f David |u The Open University x| UK TRANS 2BIND 0415164621 |P 70.00 |U 100.00 |B Hb |A |M 1 |T Creative
      Mathematics
VPR 11.99 USPRI 17.99 OTBPR 19.99 |U 25.95 |D 17/07/1997 USBDG MFDT ERT GB US CA AU NZ ZA IE ORT NRT TTY OBIND eB PDUE 11/03/2002 VIZE VEXT 192 OILLS 40 illustrations LEVEL OSER OIMP RoutledgeFalmer LIBPR OALT OPPQ OCATL This book shows how creative maths can <I>really</I> work.
      Exploring the ways in which maths skills can be learned
      through cross-curricular activities based on visual arts
      and music, the book presents maths as a meaningful and
      exciting subject which holds no fears for children.<BR> The
      authors recognise that while maths-phobia prevails in our
      increasingly mathematicised world, attitudes and
      approaches to teaching the subject need to be reviewed,
      and issues such as gender stereotyping, which encourage
      maths-apathy, need to be tackled at an early stage.<BR>
      Within this collection of classroom-based stories are
      detailed examples of integrative mathematic projects;
      these will give teachers the confidence to try out
      cross-curricular activities in their classes. The book
      also provides support with difficult areas such as
      assessment, planning and development.<BR> Fascinating to
      read in its own right this book will appeal to the
      specialist and non-specialist alike.<BR>
OCONC This book shows how creative maths can <I>really</I> work.
      Exploring the ways in which maths skills can be learned
      through cross-curricular activities based on visual arts
      and music, the book presents maths as a meaningful and
      exciting subject which holds no fears for children.<BR> The
      authors recognise that while maths-phobia prevails in our
      increasingly mathematicised world, attitudes and
      approaches to teaching the subject need to be reviewed,
      and issues such as gender stereotyping, which encourage
      maths-apathy, need to be tackled at an early stage.<BR>
      Within this collection of classroom-based stories are
      detailed examples of integrative mathematic projects;
      these will give teachers the confidence to try out
      cross-curricular activities in their classes. The book
      also provides support with difficult areas such as
      assessment, planning and development.<BR> Fascinating to
      read in its own right this book will appeal to the
      specialist and non-specialist alike.<BR>
OCATS Exploring the ways in which maths skills can be learned
      through cross-curricular projects on arts and music, this
      book presents maths as a meaningful and exciting subject
      which holds no fear for children.
OQUO 'This is a fascinating book ... which gives detailed case
      studies.' |I Infant Equipment
OCNT FCONT OWRIT VEDIT 1 BICAC U BSUB1 J BSUB2 JD BSUB3 BICAV RF SUBJ1 SB150000 SUBJ2 SUBJ3 VPROD EB VACDE WEB CREAT MFK - AUTO |D 2002 07 19 So as you see, the filed names are at the left hand side with the data starting at position 6 (5 if the line-start is 0). I usually use Excell to clean up this sort of stuff but those fields with a lot of text in them just get trashed in the process. I have used Frontier to parse ACARS logs in the past and I thought that PHP might be able to help out here. I want to be able to convert the fieldname (where it is duplicated in a record) so that each one is unique. Strip out returns, replacing with [tab] and the producing an output file that can be imported into a db (MySQL eventually but I'm using FileMaker right now). Any suggestions (that do not involve a pistol)? George in Oxford === George Pitcher HERON Technical Manager Ingenta plc 23-38 Hythe Bridge Street, Oxford, OX1 2ET T +44 (0)1865 799137 direct T +44 (0)1865 799000 switchboard F +44 (0)1865 799134 E george.pitcher@ingenta.com www.ingenta.com Ingenta: Empowering the exchange of academic and professional content online.


« previous php.windows (#18129) next »