[AccessD] Edit Large text file via VBA

Heenan, Lambert Lambert.Heenan at AIG.COM
Fri Aug 4 16:17:14 CDT 2006


Instead of 

Strtemp=space(lof(f))

and then Get() ing the whole file, define a chunk of (say) 50,000,000 bytes.

Then you need a loop to Get(CHUNKSIZE), do the replace on it, write the
chunk to the new file and then go get the next chunk.

Repeat until done.  This should be much faster that using  Line Input #1, to
process it a line at a time.

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Mark A Matte
Sent: Friday, August 04, 2006 4:25 PM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Edit Large text file via VBA


Thanks again Drew.

I might have forgotten to mention that these are farely LARGE text files.  
The one it is crashing on is 138 mb ...error= "Out of String Space"

Any other ideas?

Thanks again,

Mark A. Matte

P.S...  The largest is just over 150 mb


>From: "Mark A Matte" <markamatte at hotmail.com>
>Reply-To: Access Developers discussion and problem
>solving<accessd at databaseadvisors.com>
>To: accessd at databaseadvisors.com
>Subject: Re: [AccessD] Edit Large text file via VBA
>Date: Fri, 04 Aug 2006 19:34:42 +0000
>
>Sorry Drew...I forgot the F=Freefile
>
>Thanks again for the code.
>
>Mark A. Matte
>
>
> >From: DWUTKA at marlow.com
> >Reply-To: Access Developers discussion and problem 
> >solving<accessd at databaseadvisors.com>
> >To: accessd at databaseadvisors.com
> >Subject: Re: [AccessD] Edit Large text file via VBA
> >Date: Fri, 4 Aug 2006 14:19:00 -0500
> >
> >Can you post your code?
> >
> >Drew
> >
> >-----Original Message-----
> >From: Mark A Matte [mailto:markamatte at hotmail.com]
> >Sent: Friday, August 04, 2006 1:51 PM
> >To: accessd at databaseadvisors.com
> >Subject: Re: [AccessD] Edit Large text file via VBA
> >
> >Drew,
> >
> >Thanks for the code...I'm getting an error on the OPEN line when I 
> >execute...error="Bad file name or number"
> >
> >I even shortened the name to less than 8 characters...no spaces, just 
> >letters.
> >
> >Any ideas?
> >
> >Thanks,
> >
> >Mark A. Matte
> >
> >
> > >From: DWUTKA at marlow.com
> > >Reply-To: Access Developers discussion and problem 
> > >solving<accessd at databaseadvisors.com>
> > >To: accessd at databaseadvisors.com
> > >Subject: Re: [AccessD] Edit Large text file via VBA
> > >Date: Fri, 4 Aug 2006 13:10:33 -0500
> > >
> > >Dim f as long
> > >Dim strTemp as string
> > >F=freefile
> > >Open "C:\PathToFile\FileName.txt" for binary access read as f
> > >Strtemp=space(lof(f))
> > >Get f,,strtemp
> > >Close f
> > >Strtemp=replace(strtemp,"WhateverCharactersYouWantToReplace","")
> > >F=freefile
> > >Open "C:\NewFile.txt" for binary access write as f
> > >Put f,,strtemp
> > >Close f
> > >
> > >
> > >If you just want to replace the original file, I recommend using 
> > >the
>kill
> > >statement to delete the old file, then change the path of the last
>'open'
> > >statement to rewrite it.  If you 'write' a file that is smaller 
> > >then
>the
> > >one
> > >you are writing over, you'll get the remainder at the end.
> > >
> > >Drew
> > >
> > >-----Original Message-----
> > >From: Mark A Matte [mailto:markamatte at hotmail.com]
> > >Sent: Friday, August 04, 2006 1:02 PM
> > >To: accessd at databaseadvisors.com
> > >Subject: [AccessD] Edit Large text file via VBA
> > >
> > >Hello All,
> > >
> > >I know someone helped me do this a couple of years ago...but I 
> > >can't
>find
> > >it
> > >
> > >in my stuff or the archives.
> > >
> > >I need to search a large pipe delimited text file and remove a 
> > >string
>of
> > >characters.  I'm sure I opened it in vba and did this 'search/edit' 
> > >thing...but not sure where to start.
> > >
> > >Also...importing it is not an option due to the one of ther 
> > >characters
>I
> > >need to delete.
> > >
> > >any ideas?
> > >
> > >Thanks,
> > >
> > >Mark A. Matte
> > >
> > >
> > >--
> > >AccessD mailing list
> > >AccessD at databaseadvisors.com 
> > >http://databaseadvisors.com/mailman/listinfo/accessd
> > >Website: http://www.databaseadvisors.com
> > >--
> > >AccessD mailing list
> > >AccessD at databaseadvisors.com 
> > >http://databaseadvisors.com/mailman/listinfo/accessd
> > >Website: http://www.databaseadvisors.com
> >
> >
> >--
> >AccessD mailing list
> >AccessD at databaseadvisors.com 
> >http://databaseadvisors.com/mailman/listinfo/accessd
> >Website: http://www.databaseadvisors.com
> >--
> >AccessD mailing list
> >AccessD at databaseadvisors.com 
> >http://databaseadvisors.com/mailman/listinfo/accessd
> >Website: http://www.databaseadvisors.com
>
>
>--
>AccessD mailing list
>AccessD at databaseadvisors.com 
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list