Slow String Handling in VBScript - Help!

Results 1 to 3 of 3

Thread: Slow String Handling in VBScript - Help!

  1. #1
    Join Date
    Dec 1969

    Default Slow String Handling in VBScript - Help!

    I have a 300,000-line text file (each line 600 chars wide) that put into the Stream object. Then I use the Stream.ReadText functionality to read each line and cut it up into ADO recordset columns. I manufactured the ADO recordset in-memory, it is not the result of any SQL.<BR><BR>Anyway, I am doing this 300,000 times, and was wondering if there is any code which might be faster:<BR><BR>Do While Not oStream.EOS<BR>cTempLine = oStream.ReadText(350)<BR>If Left(cTempLine,2) = "81" Then<BR> oMyRS.AddNew arRecArray , Array ( _<BR> Mid(cTempLine,1,2) , _<BR> Mid(cTempLine,3,20) , _<BR> Mid(cTempLine,23,20) , _<BR> Mid(cTempLine,43,3) , _<BR> Mid(cTempLine,46,7) , _<BR> Mid(cTempLine,53,2) , _<BR> Mid(cTempLine,55,3) , _<BR> Mid(cTempLine,58,8) , _<BR> Mid(cTempLine,66,8) , _<BR> Mid(cTempLine,74,8) , _<BR> Mid(cTempLine,82,8) , _<BR> Mid(cTempLine,90,8) , _<BR> Mid(cTempLine,98,1) , _<BR> Mid(cTempLine,99,30) , _<BR> Mid(cTempLine,129,30) , _<BR> Mid(cTempLine,159,2) , _<BR> Mid(cTempLine,161,2) , _<BR> Mid(cTempLine,163,30) , _<BR> Mid(cTempLine,193,30) , _<BR> Mid(cTempLine,223,30) , _<BR> Mid(cTempLine,253,30) , _<BR> Mid(cTempLine,283,30) , _<BR> Mid(cTempLine,313,8) , _<BR> Mid(cTempLine,321,2) , _<BR> Mid(cTempLine,323,1) , _<BR> Mid(cTempLine,324,2) , _<BR> Mid(cTempLine,326,2) , _<BR> Mid(cTempLine,328,12) , _<BR> iLineCounter , _<BR> iQueueID , _<BR> "Unknown ID" _<BR> )<BR>oMyRS.UpdateBatch<BR>End If<BR>iLineCounter = iLineCounter + 1<BR>oStream.SkipLine<BR>Loop<BR><BR>Thanks.

  2. #2
    Join Date
    Dec 1969

    Default RE: Slow String Handling in VBScript - Help!

    JScript would do it quicker.

  3. #3
    Join Date
    Dec 1969

    Default But not enough to matter...

    Yeah, JScript would be a *little* faster at something like this, but the right solution is clearly to use a component. Esp. a C++ component.<BR><BR>With C++ you could read the entire file into a huge buffer and then just do some *really* fast processing.<BR><BR>Hmmmm...well, not as fast as I first thought. You&#039;d have to copy each line into a buffer with space to put the nulls in between the strings. Hmmm...well, maybe a trick or two to play there! Using a pair of buffers and flipflopping back and forth. Yeah. That would work. And then only one "memcpy" needed instead of a bunch of them. Yeah, with C++ (or C, to be fair to an obsolete language) you&#039;d *definitely* be limited to the speed of the DB processing.<BR><BR>Another idea: Use a component to convert the file from the ugly fixed-record format into a ".csv" file and then just let the DB import that. <BR><BR>Actually, some DBs (e.g., MySQL) *can* import fixed format files like that one directly! Dunno know if SQL Server can. I wouldn&#039;t be surprised, though.<BR><BR>

Posting Permissions

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