|
-
July 18th, 2005, 07:41 AM
#1
Reading In a Space delimited File
I was wondering what the best way to read in a space delimited file would be? I would love to just do a ReadLine() followed by a String.Split(" ") but the problem is that there is a variable amount of spaces between the values, not just one. Is there a way to make String.Split() treat consecutive delimiters as one? If not, what is the best way to read in a line of values and split them up? I have code that does this by reading one character at a time, checking if it is a space or tab and then reading and discarding until another non-space, non-tab character is found. It's pretty tedious though and I was wondering if there was an easier method.
- Tom
-
July 18th, 2005, 09:02 AM
#2
Re: Reading In a Space delimited File
TSmooth,
you can replace two spaces at a time in a loop before using split
Code:
While s.IndexOf(" ") >= 0
s = s.Replace(" ", " ")
MsgBox(s) ' just to see the progress
End While
Hope it helps
Did it help? rate it.
The best conversation I had was over forty million years ago ... and that was with a coffee machine.
-
July 18th, 2005, 09:21 AM
#3
Re: Reading In a Space delimited File
You could also do the usual Split() with space/tab and then discard the undesirable entries by looping through the resulting array.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|