Stripping of unwanted data from text file 
Author Message
 Stripping of unwanted data from text file

I have a text file with quotation marks and commas which I would like to
delete.  I intend to create a routine/procedure with VB to input this file,
parse the file - copying exactly all contents except the quotation marks and
commas, and writing the results to another text file.  How can I do that?
Or where can I find guides/links for me to achieve that?  What driver should
I use?

Thanks,
ST



Mon, 24 Feb 2003 15:32:49 GMT  
 Stripping of unwanted data from text file
Instead of creating an all new file what you can do is test each string
before using it to make sure there are no apostrophes.

If InStr(strName, "'") > 0 Then
    For Count = 1 To Len(strName)
        Char = Mid(strName, Count, 1)
        If Char = "'" Then
            Buffer = Buffer
        Else
            Buffer = Buffer & Char
        End If
    Next
    (function) = Buffer

It is mighty slow, though.

Charles Carroll

--
Desert Sea Publishing Co.                http://www.desertsea.com
112 Hope Farm Road                      Horse Racing Books
Socorro, New Mexico  87801         Software, and Videos

Quote:

> I have a text file with quotation marks and commas which I would like to
> delete.  I intend to create a routine/procedure with VB to input this
file,
> parse the file - copying exactly all contents except the quotation marks
and
> commas, and writing the results to another text file.  How can I do that?
> Or where can I find guides/links for me to achieve that?  What driver
should
> I use?

> Thanks,
> ST



Mon, 24 Feb 2003 20:38:55 GMT  
 Stripping of unwanted data from text file

I've found my solution and would like to share out:

Open OriginalTextFile as Input for #1
Open ModifiedTextFile as Output for #2
Do While Not (EOF(1))
    Input #1 StringVar1, StringVar2, StraingVar3, StringVar4, IntVar1,
IntVar2, IntVar3
    Print #2 StringVar1, StringVar2, StringVar3, StringVar4, IntVar1,
IntVar2, IntVar3
Loop
Close #1
Close #2

This way, with OriginalTextFile contents of:
"StringVar1","StringVar2","StringVar3","StringVar4",IntVar1,IntVar2,IntVar3
"ABC","DEF","GHI","JKL",123,234,345

will become ModifiedTextFile of:
StringVar1  StringVar2  StringVar3  StringVar4  IntVar1  IntVar2  IntVar3
ABC  DEF  GHI  JKL  123  234  345

ST


Quote:
> Instead of creating an all new file what you can do is test each string
> before using it to make sure there are no apostrophes.

> If InStr(strName, "'") > 0 Then
>     For Count = 1 To Len(strName)
>         Char = Mid(strName, Count, 1)
>         If Char = "'" Then
>             Buffer = Buffer
>         Else
>             Buffer = Buffer & Char
>         End If
>     Next
>     (function) = Buffer

> It is mighty slow, though.

> Charles Carroll

> --
> Desert Sea Publishing Co.                http://www.desertsea.com
> 112 Hope Farm Road                      Horse Racing Books
> Socorro, New Mexico  87801         Software, and Videos


> > I have a text file with quotation marks and commas which I would like to
> > delete.  I intend to create a routine/procedure with VB to input this
> file,
> > parse the file - copying exactly all contents except the quotation marks
> and
> > commas, and writing the results to another text file.  How can I do
that?
> > Or where can I find guides/links for me to achieve that?  What driver
> should
> > I use?

> > Thanks,
> > ST



Tue, 25 Feb 2003 10:39:49 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. NEWBIE:Function to strip off unwanted characters

2. Stripping data out of text w/VB 4.0

3. STRIPPING LINES FROM A TEXT FILE?

4. newbie: strip the carriage returns from a text file

5. Unwanted characters inserting text as DocVariable

6. Unwanted Underling of Text in a Form Field

7. Unwanted Rich Text formatting cahracters

8. Unwanted scrolling on entryfield when all text selected

9. Formula needed to delete unwanted text in a field

10. Unwanted "External Data" Toolbar

11. Unwanted click events in VB5 with data control and dbCombos

12. can't access data from text file use Data control

 

 
Powered by phpBB® Forum Software