1. Problem using walk_dir
- Posted by Joel Garcia <heyjoel at comcast.net> Nov 09, 2005
- 433 views
- Last edited Nov 10, 2005
I have created a small program to strip content from a series of HTML files and store this new data in a CSV formatted text file. The problem I am experiencing is in regard to the walk_dir command for parsing each HTML file. The files have all been examined and tested individually to be sure they can be stripped by my routine. But what is happening is that after the first 18 files are read, the program ends without processsing file 19 and never continues beyond that. Below is a shortened version of my code showing how I have used walk_dir. If someone knows what it is I have omitted or done incorrectly, I would appreciate the help and advice. It's just a quick and dirty program at the moment, but I need to get this functioning properly before moving on to refine the rest of it. Thank you in advance. Joel ===Sample code=== include get.e include keys.e include fileio.e constant output_file = "output.txt" object exit_code integer fn, fn_out fn_out = open(output_file, "w") function look_at(sequence path_name, sequence entry) sequence input_file input_file = path_name & "\\" & entry[1] printf(fn_out, "%s", {input_file}) printf(fn_out, "%s", {"\n"}) fn = open(input_file, "r") if fn = -1 then puts(1, "Couldn't open file\n") abort(1) end if return 0 -- 0 to keep going end function exit_code = walk_dir("C:\\EUPHORIA\\My Programs\\My Files", routine_id("look_at"), 0)
2. Re: Problem using walk_dir
- Posted by Greg Haberek <ghaberek at gmail.com> Nov 09, 2005
- 420 views
- Last edited Nov 10, 2005
> I have created a small program to strip content from a series of HTML fil= es and store this new data in a CSV formatted text file. The problem I am = experiencing is in regard to the walk_dir command for parsing each HTML fil= e. The files have all been examined and tested individually to be sure the= y can be stripped by my routine. But what is happening is that after the f= irst 18 files are read, the program ends without processsing file 19 and ne= ver continues beyond that. Are the files in separate directories or sub-folders?
3. Re: Problem using walk_dir
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Nov 09, 2005
- 422 views
- Last edited Nov 10, 2005
Joel Garcia wrote: > > I have created a small program to strip content from a series of HTML files > and store this new data in a CSV formatted text file. The problem I am > experiencing > is in regard to the walk_dir command for parsing each HTML file. The files > have all been examined and tested individually to be sure they can be stripped > by my routine. But what is happening is that after the first 18 files are > read, > the program ends without processsing file 19 and never continues beyond that. > <snip>
function look_at(sequence path_name, sequence entry) sequence input_file input_file = path_name & "\\" & entry[1] printf(fn_out, "%s", {input_file}) printf(fn_out, "%s", {"\n"}) fn = open(input_file, "r") if fn = -1 then puts(1, "Couldn't open file\n") abort(1) end if return 0 -- 0 to keep going end function
You never close the files, so eventually, you run into the open file limit. Add a "close(fn)" before the "return 0" and it should work correctly. Matt Lewis
4. Re: Problem using walk_dir
- Posted by Joel Garcia <heyjoel at comcast.net> Nov 09, 2005
- 427 views
- Last edited Nov 10, 2005
Matt Lewis nailed it for me. I was neglecting to use a close() when finished with each file, so I ended up maxing the number of open files allowed. Thanks for helping.
5. Re: Problem using walk_dir
- Posted by Joel Garcia <heyjoel at comcast.net> Nov 09, 2005
- 421 views
- Last edited Nov 10, 2005
That was it, Matt. Thanks very much. I knew it was something I was overlooking.
6. Re: Problem using walk_dir
- Posted by "Juergen Luethje" <j.lue at gmx.de> Nov 09, 2005
- 417 views
- Last edited Nov 10, 2005
Joel Garcia wrote: > I have created a small program to strip content from a series of HTML > files and store this new data in a CSV formatted text file. The > problem I am experiencing is in regard to the walk_dir command for > parsing each HTML file. The files have all been examined and tested > individually to be sure they can be stripped by my routine. But what > is happening is that after the first 18 files are read, the program > ends without processsing file 19 and never continues beyond that. > > Below is a shortened version of my code showing how I have used > walk_dir. > If someone knows what it is I have omitted or done incorrectly, I would > appreciate the help and advice. It's just a quick and dirty program at > the moment, but I need to get this functioning properly before moving > on to refine the rest of it. Thank you in advance. > > Joel > > ===Sample code=== > > include get.e > include keys.e > include fileio.e > > constant output_file = "output.txt" > > object exit_code > integer fn, fn_out > > fn_out = open(output_file, "w") > > function look_at(sequence path_name, sequence entry) > sequence input_file > > input_file = path_name & "\\" & entry[1] > printf(fn_out, "%s", {input_file}) > printf(fn_out, "%s", {"\n"}) > fn = open(input_file, "r") > if fn = -1 then > puts(1, "Couldn't open file\n") > abort(1) > end if -- process file contents, and then ... close(fn) > return 0 -- 0 to keep going > end function > > exit_code = walk_dir("C:\\EUPHORIA\\My Programs\\My Files", > routine_id("look_at"), 0) You should close the files anyway. Maybe this already solves the problem. Regards, Juergen -- Have you read a good program lately?