Your problem is the fact that you have a variable number of space characters separating your values, and you are only cleaning some of them up. You actually don't get "only 2 columns", but many more, but quite a few values are zero. remember, your separator is set to \s, so if you have more than one consecutive \s you'll get extra zeroes.
Your code is way too complicated for such a simple task! A much better solution would be to use "scan strings for tokens". By default, empty tokens are not allowed, thus multiple separators are automatically contracted into one. We no longer neet to strip extra spaces!
We need to do it in two easy steps:
- Get each line using \r or \n as seperators (outer WHILE loop)
- for each line, get the four values, using \s or \t as seperators (inner FOR loop).
- To save memory, you can convert each value to DBL in the inner loop directly and form the array using autoindexing.
I have attached a VI showing this procedure (LabVIEW 7.1). It seems to work fine. I think you agree that it is simpler. 🙂
Let me know if you have any questions. Happy coding. 🙂