Page 1 of 1 1
Topic Options
#156437 - 2006-02-01 06:51 PM Is a 16MB text file too big to parse??
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
I have a text file that's 16MB and when I run a script I'm writing on it, just a black screen comes up and nothing happens. Is there a max size on the text file size that KiX can parse?

Code:
Break On

$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapatEOL','On')

$report = ReadFile(@ScriptDir+'\'+'test.txt')

For Each $line in $report
? $line
; $split = Split($line," ")
; ? $split[0]
Next


Top
#156438 - 2006-02-01 08:52 PM Re: Is a 16MB text file too big to parse??
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
I have done bigger files, only time I ran into an issue was with a 1.5GB file and I ran out of memory on that one.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#156439 - 2006-02-01 09:15 PM Re: Is a 16MB text file too big to parse??
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
Thanx gargoyle... I moved away from using the ReadFile() function and just used Open() and it worked fine.
Top
#156440 - 2006-02-01 09:58 PM Re: Is a 16MB text file too big to parse??
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what bigger file, that longer readfile takes to execute, obviously.
but if it takes more than few seconds, it would be odd.
_________________________
!

download KiXnet

Top
#156441 - 2006-02-01 11:18 PM Re: Is a 16MB text file too big to parse??
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
I sat there and watch a black screen not do anything for 3 mins before I closed it. Now that I have it working, it's parsing all lines of the 16MB text file in less than 20 secs.
Top
#156442 - 2006-02-02 12:52 AM Re: Is a 16MB text file too big to parse??
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, adding some output into your readfile code would show what's going on.
_________________________
!

download KiXnet

Top
#156443 - 2006-02-02 03:19 AM Re: Is a 16MB text file too big to parse??
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
That's pretty much what I was saying, there was supposed to be output going the screen but a black screen would pop up with nothing scrolling like it should...
Top
#156444 - 2006-02-02 10:21 AM Re: Is a 16MB text file too big to parse??
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
ReadFile() is a function which loads the entire file into an array. Functions don't return until they have finished, so your code which displays the results also cannot execute until the entire file has been read.

The function is building a version of the file in memory. This means that for every line read, it has to manipulate the data that it already has. As you get further into the file this gets less and less efficient, and at the same time you are using up a lot of memory so your computer starts to struggle with all it's tasks.

For this reason, nothing will appear on your screen for a long time.

As you've seen, ReadFile() is a great convenience for small files, but not a good choice for large files where you only want to perform a serial read.

Jooels recommendation was to add debug code to the ReadFile() function, not your calling code.

Top
#156445 - 2006-02-02 08:22 PM Re: Is a 16MB text file too big to parse??
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
ahh... thanx for clearing that up Richard. Again, I'm a noob at KiX so I apologize for my often-trivial posts.
Top
#156446 - 2006-02-02 09:10 PM Re: Is a 16MB text file too big to parse??
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Quote:

often-trivial posts




No problem... no more trivial than many of the ones posted even by Moderators.

As long as we're all learning more and able to perform our jobs better then I think this board is doing a great job.

Top
#156447 - 2006-02-03 10:28 AM Re: Is a 16MB text file too big to parse??
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Your post is not at all trivial. Sometimes the way that programs or scripts work is not immediately obvious, even to experienced programmers.

It is good to have these questions asked as it allows us to post a response that will help people with the same issue.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 857 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.061 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org