How do I read a text file that contains double quotes separate by commas?

I have a text file that contains the following format:
" ", " ", " ",Marie Smith, " ", 23 Main ST, " "
" ", " ", " ",Joe Brown, " ", 222 West St, " "

I only need to grab the name and address fields, how do I accomplish this in VB? Any samples? Thanks so much for your help

MGirl
[304 byte] By [mgirl] at [2007-11-18 2:14:55]
# 1 Re: How do I read a text file that contains double quotes separate by commas?
check out the "split" function in the on-line help
phinds at 2007-11-10 0:02:30 >
# 2 Re: How do I read a text file that contains double quotes separate by commas?
'Do the following:

dim tmpSplit () as string

tmpSplit = Split (yourLine,",",-1,vbTxtCompare)

'now loop thru tmpSplit

for i% = 0 to UBound(tmpSplit)
if tmpSplit(i%) <> "" then
'do something
endif
next
rubiCube at 2007-11-10 0:03:30 >
# 3 Re: How do I read a text file that contains double quotes separate by commas?
Ok ... Try this and do pull up the VB help on these ...

Open "YourFileNameHere" for input as #1
input #1, YourVariableHere
Close #1

This will get you on your way ...

- Mike
M Owen at 2007-11-10 0:04:39 >
# 4 Re: How do I read a text file that contains double quotes separate by commas?
Thank you guys so much for your replies. I think I'm almost there.

But here's my problem:

VB does not recognize the double quotes "" in the text files as being the same as the one here if tmpSplit(i%) <> ""

Please help!!!
Thanks
mgirl at 2007-11-10 0:05:33 >
# 5 Re: How do I read a text file that contains double quotes separate by commas?
You're testing if the string is empty versus testing for a set of quotations ... i.e.

if TestString <> "\"\"" then
' Do something
endif
M Owen at 2007-11-10 0:06:34 >
# 6 Re: How do I read a text file that contains double quotes separate by commas?
mgirl
try this for comparison

tmpSplit(i%) <> """ """

I hope this will solve your problem
:o
rubyash at 2007-11-10 0:07:33 >
# 7 Re: How do I read a text file that contains double quotes separate by commas?
I tried both solutions:
tmpSplit(i%) <> """ """



if TestString <> "\"\""

But it still doesn't work. Any other suggestions. Thanks
mgirl at 2007-11-10 0:08:37 >
# 8 Re: How do I read a text file that contains double quotes separate by commas?
Just got done test this:

teststr = """"
If teststr = """" Then MsgBox "Hallalulah!"

It works ... The other stuff was the C programmer in me ... :D

- Mike
M Owen at 2007-11-10 0:09:39 >
# 9 Re: How do I read a text file that contains double quotes separate by commas?
Here's the code I'm running and also attached the names text file:

It really puzzles me that it's not working. Please try it and let me know what you get. Thanks so much

Dim tmpSplit() As String

Open "C:\names.txt" For Input As #1

Do While Not EOF(1)
Line Input #1, Lineread
tmpSplit = Split(Lineread, ",", -1, 1)

'now loop thru tmpSplit

For i% = 0 To UBound(tmpSplit)

If tmpSplit(i%) <> """" Then
'do something
MsgBox tmpSplit(i%)
End If

Next

Loop

Close

End Sub
mgirl at 2007-11-10 0:10:36 >
# 10 Re: How do I read a text file that contains double quotes separate by commas?
Do you get any message box popups at all?
M Owen at 2007-11-10 0:11:36 >
# 11 Re: How do I read a text file that contains double quotes separate by commas?
yes I do
I get both fields displayed the one with the "" and the other with text.
what's wrong with me?
Please help!!!
mgirl at 2007-11-10 0:12:45 >
# 12 Re: How do I read a text file that contains double quotes separate by commas?
You get "fields"? The data you showed us should have a bunch of popup msgbox's ... Let's focus the problem on getting you the data you want to find ... Now 1 thing you can do is test for both not " " AND a length > 3 ... One thing I noticed on looking closely at your data ... Those empty strings have a space in them ... Is this correct? If so, then modify your conditional to skip them ->

if Tmpsplit(i%) <> "" "" then

The length test would be like:

if len(tmpsplit(i%)) > 3 then

Try something like that ...

- Mike
M Owen at 2007-11-10 0:13:44 >
# 13 Re: How do I read a text file that contains double quotes separate by commas?
Wonderful!!!!!
The greater than 3 did the trick.
Thanks so much.

Next I need to figure out how to write this data to a new text file. Any ideas?

Thanks again
mgirl at 2007-11-10 0:14:46 >