From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do i convert a spreadsheet string to an array of double with out using spreadsheetstringtoarray.vi?



@chilly charly wrote:


@adrianT wrote:
Hi

Thanks for that.

But your method produces just one column of data. I need two.


Thank you.


When I use the vi on the data you provided, I get two columns. You can see that by yourself on the attached vi, where I have saved the calculated results as default values (there is an additionnal modification to read directly a file). Are you making tests on different sets of data ? Could you give me an example of what's returned by my vi. Or are you using a modified version of my vi ? In this last case, could you post it ?

CC






Hi

Yes. I am using different sets of data. The important thing to note is that some of our data has tab-space, 4 spaces and 1 space as delimeters. What I am attempting to do is to write a general vi that handles all types of delimeters and other characters that we do not want.

I hope this make sit a little bit clearer.


Thank you.
0 Kudos
Message 11 of 19
(1,122 Views)
Well, if you do not give a proper description of your problem, or appropriate examples, it will be quite difficult to any of us to spend more time here and give you more help than you received so far. Sorry...

CC
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
0 Kudos
Message 12 of 19
(1,119 Views)


@adrianT wrote:


@chilly charly wrote:


@adrianT wrote:
Hi

Thanks for that.

But your method produces just one column of data. I need two.


Thank you.


When I use the vi on the data you provided, I get two columns. You can see that by yourself on the attached vi, where I have saved the calculated results as default values (there is an additionnal modification to read directly a file). Are you making tests on different sets of data ? Could you give me an example of what's returned by my vi. Or are you using a modified version of my vi ? In this last case, could you post it ?

CC






Hi

Yes. I am using different sets of data. The important thing to note is that some of our data has tab-space, 4 spaces and 1 space as delimeters. What I am attempting to do is to write a general vi that handles all types of delimeters and other characters that we do not want.

I hope this make sit a little bit clearer.


Thank you.





Here is what we have got.
0 Kudos
Message 13 of 19
(1,116 Views)
Hi,

Please find the attached VI useful, if not to the exact, in getting your problem solved.

With regards
(Kindly rate my VI to tell me how useful/ helpful it is, thanks :))

Message Edited by ian.f on 05-17-2005 01:41 AM

Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
0 Kudos
Message 14 of 19
(1,114 Views)
After removing all spaces behind line feed, and replacing multiple spaces with single tabs, it seems that the file is properly cleaned to be converted in a two columns 2D array.
And no loop (just hidden behind the Search&Replacle Pattern vi :)).

CC
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
0 Kudos
Message 15 of 19
(1,090 Views)
Hi

Thanks for your help. Your solution worked well and is in the process of being used.

I have got another problem. This time there are 4 columnns of data. I tried your solution and the first two columns were extracted okay but there were zeroes in between the other two columns.

I have attached some example files for you to play with.


Thank you.
0 Kudos
Message 16 of 19
(1,076 Views)
Adrian,

I would not do all these complicated string operations, LabVIEW is supposed to be easy ;). Here's a quick example that incorporates my first suggestion above. It seems to work OK even with these latest data files, but please check for yourself. (LabVIEW 7.0)

Let me know if you see any issues so we can tweak it a little bit more. 🙂
Message 17 of 19
(1,073 Views)
Adrian,
again, I don't observe added zeroes with the text files you provided. Could you post a non-working test file ?

Christian,
I like the scan string for tokens function. Never used it before. 5 peanuts for that.
But you forgot to remove the file header. That adds rows of zeroes.

How about testing the different methods on the attached nightmare file (no empty element) ?
My solution is a slight modification of my previous vi

CC

Message Edited by chilly charly on 05-19-2005 09:24 AM

Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
Download All
0 Kudos
Message 18 of 19
(1,066 Views)

@chilly charly wrote:
But you forgot to remove the file header. That adds rows of zeroes.

It works perfectly for the latest set of sample files (4 columns), because the header is all blank and the first line is "real" zeroes that should probably stay. (This is because "empty tokens are skipped by default).

Going higher up with the file "test.txt" the header is a bit more complex so we need some "tweaks".

Most often, the header has a well-known structure (e.g. first 10 lines) so it can be clipped by some simple counting. I would recommend that. In this particular case we can also count elements/line and retain only lines that have more than one element.
The attached simple modification (102) tosses all lines with only one element and thus also works on test.txt.
(OTOH: Could it be that the first real line of test.txt (141 2) is also part of the header? It somehow sticks out. ;))

(It would still fail if one of the header lines contains separators. Modification 103 drops any lines that contain either (1) only one element OR (2) contain anything non-numeric. The trick is to wire NaN as default value for Fract/Exp String to Number, then test for it. Any garbage item will generate NaN which is better than the default behavior that generates zero under these conditions).

Message Edited by altenbach on 05-19-2005 01:47 AM

Download All
Message 19 of 19
(1,055 Views)