Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2006
    Posts
    127

    Huh? Can TextFile.ReadToTable be speeded up?

    I need to read 6MB text files to tables (around 20,000 short lines of text). An update of the progress bar would be good but I do not understand why the read takes a month of Sundays in the first place - the files load instantly into plain text editors for example.

    Has anyone hit this problem and found a solution?

    Also, neither ReadToTable or ReadToString handle Unix/Mac text files correctly, only the first line is read. Anybody know a way around that gotcha programmatically?

  2. #2
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    Quote Originally Posted by IdeasVacuum View Post
    Can TextFile.ReadToTable be speeded up?
    no.

    Consider writing your routines in C and make a dll or exe to do the processing.

    Remember, you're using a SCRIPTING language, it's not compiled.... so you can't expect pure speed out of it.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  3. #3
    Join Date
    Oct 2009
    Location
    Merton, United Kingdom
    Posts
    684
    Quote Originally Posted by IdeasVacuum View Post
    I need to read 6MB text files to tables (around 20,000 short lines of text). An update of the progress bar would be good but I do not understand why the read takes a month of Sundays in the first place - the files load instantly into plain text editors for example.

    Has anyone hit this problem and found a solution?

    Also, neither ReadToTable or ReadToString handle Unix/Mac text files correctly, only the first line is read. Anybody know a way around that gotcha programmatically?
    Have you tried using the Lua Input/Output model?

    This way you'll be able to give progress while reading line by line.

    Pseudo-code, probably won't work.

    Code:
    local myfile = io.open("C:\\myfile.txt", "rb");
    local contents = {};
    
    while (myfile) do
    	table.insert(contents, myfile:read("*line"));
    end

  4. #4
    Join Date
    Apr 2006
    Posts
    127
    I have not seen that function before, thanks Sakuya.

  5. #5
    Join Date
    Apr 2006
    Posts
    127
    Hello jassing

    Of course I appreciate that scripting is much slower than compiled code, but in this case it seems to be slower than one might reasonably expect - perhaps vbs would win that race.

    Anyway, I have bitten the bullet and coded the same task in PureBasic (Demo), which processes the entire job (6MB in, 6MB out) in less than 2 seconds (1 hour+ in AMS). Now that PB performance surprised me, it is much faster than a similar project I wrote in C++ (pure code, no .Net).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts