rusty.hammond at cpiqpc.com
rusty.hammond at cpiqpc.com
Fri Aug 4 15:46:39 CDT 2006
Would something like the following work? This would read the text file one
line at a time so it assumes a carriage return or carriage return+line feed
at the end of each line of your text file.
Function CleanFile()
Dim strInputFile as string
Dim strOutputFile as string
Dim strTextLine as string
strInputFile = "c:\pathtofile\filename.txt"
strOutputFile = "c:\pathtofile\newfilename.txt"
Open strInputFile For Input As #1
Open strOutputFile For Output As #2
Do While Not EOF(1)
Line Input #1, strTextLine 'Get text lines from the original file
strTextLine =
Replace(strTextLine,"WhateverCharactersYouWantToReplace","")
Print #2, strTextLine 'Print the text lines to the new text
file
Loop
Close #1
Close #2
Kill strInputFile
End Function
-----Original Message-----
From: Mark A Matte [mailto:markamatte at hotmail.com]
Sent: Friday, August 04, 2006 3: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
**********************************************************************
WARNING: All e-mail sent to and from this address will be received,
scanned or otherwise recorded by the CPI Qualified Plan Consultants, Inc.
corporate e-mail system and is subject to archival, monitoring or review
by, and/or disclosure to, someone other than the recipient.
**********************************************************************