| |||||||||||
| |||||||||||
reading a text file and extracting info Posted by esen (esen), 2 November 2005 hi peeps, im hoping someone can help...im having a problem reading the text file and outputting a matrix type display which has the links along the x and y co-ordiantes (or an abbreviation) and 0 or 1 in the matrix if the page did link to another page (1) or didnt (0). I have a text file made up of links in the form of Visited: http://www... Link: http://www.whatever url Link: http://www.whatever url Link: http://www.whatever url Link: http://www.whatever url Visited: http://www.whatever url Link: http://www.whatever url Link: http://www.whatever url Link: http://www.whatever url Link: http://www.whatever url etc..im having a problem reading the text file and outputting a matrix type (table) display which has the urls along the top and left side (or an abbreviation) and 0 or 1 in the matrix if the page did link to another page (ie puts in a 1 in the matrix display ) or didnt (puts in a 0). for instance Visited: A Link: B Link: C In the matric A couldnt link to itself so a 0 would be put in the matric. A does link to B so a 1 would be output in the matrix..and so on. would really appreciate some help.. as im fast going grey ![]() thanks all! Posted by admin (Graham Ellis), 2 November 2005 I think you're looking for something like this:Code:
Which runs to give Code:
I'm not sure I understood the question fully though .. so I won't go into a long explanation in case I got it wrong. It was fun writing that anyways! Posted by esen (esen), 3 November 2005 thanks!...i will try to see whats going on ![]() Posted by esen (esen), 3 November 2005 hmmm my head hurts..sorry, which bit does the file reading...probably a very basic question... ![]() Posted by admin (Graham Ellis), 3 November 2005 In my example, I've used <DATA> to read from the same file as the program is in, after the __END__ marker. It's a great way of writing a demo as it means that the whole thing is selfcontained.You'll want to open a file in the usual way, and read from it in your while loop ... This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |