Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The contents of files looks like below with the data i require in a table.
The text before and after the table is just general information but varies from file to file that i read, there can be other tables after the one i am tring to read but this must be ignored.
I feel the only way to get this data is to search for words 'Bus Timetable' as this not repeated any where else in the files. But to get the data i require, i need to look at the forth line from 'Bus Timetable'. I then need to some how get the FROM DEPT TO & ARR in the order they are in table, in the following way- FROMDEPT:TOARR ( i.e. twn0900:apt0911 ). I think to stop retrieving the data it can stop when it sees the next + as this is on the last line of the table.
---TEXT BEFORE--- +---------------+ | Bus Timetable | +---------------+----+------------+-----------+------+ | BUS SERVICE DAY tm | FROM DEPT | TO ARR | 24/7 | +--------------------+------------+-----------+------+ | C4 metro mon 15 | twn 0900 | Apt 1011 | yes | | C6 intl mon 45 | LDN 1000 | XTR 1426 | no | | B2 susx mon 20 | cly 1034 | btn 1118 | no | | A0 xxxxx xxx xx | xxx xxxx | xxx xxxx | xxx | +--------------------+------------+-----------+------+ ---TEXT AFTER---
I have noticed that the file produced can continue the table on the next page but puts the name of table and the headings for the columns as before. So i would like the program to read all tables with 'Bus Timetable' heading but ignore any other tables and text.
So far i have not written any code as i am not sure how to do this as i have been learning perl only 4 weeks now. I think i understand what i want the code to do and that it is possible to do what i have asked. I know how to search for a word but i dont not know how to look a number of lines from the result of search and to look at the table. I guess it should count the number of '|' and get data between the 2 and 4 one?
If any one can help me i will be very thankful
Thank you all so much, Kwun Chang.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: read text table
by ctilmes (Vicar) on Oct 20, 2003 at 10:44 UTC | |
|
Re: read text table
by Skeeve (Parson) on Oct 20, 2003 at 10:40 UTC | |
|
Re: read text table
by allolex (Curate) on Oct 20, 2003 at 11:00 UTC | |
|
Re: read text table
by Roger (Parson) on Oct 20, 2003 at 11:20 UTC | |
|
Re: read text table
by Anonymous Monk on Oct 20, 2003 at 11:31 UTC | |
by ctilmes (Vicar) on Oct 20, 2003 at 11:37 UTC | |
by Anonymous Monk on Oct 20, 2003 at 12:17 UTC | |
|
Re: read text table
by Anonymous Monk on Oct 20, 2003 at 13:11 UTC | |
by Anonymous Monk on Oct 20, 2003 at 19:04 UTC |