LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search for alphabets A - Z

Hello Sture,

Thanks for your help, but I'm running into a little problem and I hope you can bail me out this time too!

I transcribed your code into the intitial part of my program to see if it extracted the data, and I'm running into a couple of problems:

-I'm having difficulty writing the cluster out. (I've never done that before). I looked at discussions online, and they recommend writing the header using "Write to Text File" and then appending the array to this using "Write to Spreadsheet". Is this the only way? I tried doing that, but what happens it is it writes the first 2 lines, but fails to write the y, z, and other variable headers. I am guessing that it closes the file before building the string array completely before writing.

- In older versions of labview, there used to be a function that was merely "Create File", "Open File" and "Write to File". Would using these be a better option?

I'm running labview 8.0.1.

Thanks!

Janak
0 Kudos
Message 11 of 26
(2,126 Views)


@mechanical13 wrote:
Is this the only way?

OK, a file is just a long collection of characters. Easiest would be to just format it as a string in memory (using e.g. "array to spreadheed string", concatenate string, etc), then write it to a file using "write text" in one operation. There is no reason to form clusters and other acrobatics. 😉

You should really be careful with your extensions, because your files are plain ASCII tables and not excel files as you seem to imply from the .xls extension. If you would ever open these files in excel and save them in excel, you will no longer be able to read them with your simple LabVIEW program. Sometimes, giving an .xls extension is done for convenience so it open in excel when double-clicked. You just need to be aware that it is actually not an excel file under the hood. 😉

I still think your code is way too complicated for this simple task.

0 Kudos
Message 12 of 26
(2,122 Views)
Let's look once more at your file. It seems to have excellent delimiters to seperate headers from data and seperate out datasets.
 
The pattern seems to be:
 
(("title 1")
(x
"single column data 1"
)
)
(("title 2")
(x
"single column data 2"
)
)
 
....etc.
 
Also, it seems you want to have a single output file as follows, one dataset per column:
 
"title 1" "title 2" ...
data 1  data 2 ...
 
You cannot do this by "appending" to a file! 🙂
 
All you need is to get the titles and datasets between the special delimiters, format it into a spreadsheet string as above, and write it to the output file once.
0 Kudos
Message 13 of 26
(2,120 Views)

OK, here's a quick draft how you could do it. Seems to work in a blink, even with your 2MB data file. 🙂

(I also attached a small testfile with multiple datasets for testing).

Be aware that your datafile is too big to be loaded into excel. My version of excel truncates it at 64k lines. 😞

Right now it only processes files with a "*.txt" extension (see pattern input to "list folder"). You should adjust that to the real extension of your files. It also probably needs better error handling. You should maybe also strip the .txt extension from the output file, right now it generates files abc.txt.xls. is that what you really want?

I also don't go through the expense of scanning the number to DBL and formatting them again later. I just operate on the numeric strings.

See if this makes sense to you. Modify as needed. Good luck! 🙂

Message Edited by altenbach on 09-18-2007 09:10 PM

Download All
Message 14 of 26
(2,111 Views)
Hi,

Thanks for your help. Don't have labview on this computer, so will change computers at work and check out your code.

The pattern I'm interested in is:


(x
"Column of x data"
)
(y
"Column of y data"
)
(z
"Column of z data"
)
(variable1 ---------- number of variables and varible names are unknown
"Column of variable1 data"
)
(variable2 ---------- number of variables and variable names are unknown
"Column of variable2 data"

etc etc, until the end of the file is reached.

The end of the file contains an extra ) to close the ( that was placed at the beginning of the file.

I believe that I'll have to change the search strings on your code to make it recognize this pattern. Let me give it a try and get back to you.

Appreciate all your help!
0 Kudos
Message 15 of 26
(2,087 Views)
Hi Again,

I haven't tried the codes, but what I'd like to do is extract this long columnar dataset into x, y, z, and unknown number of variables as columns in excel. I would like each data file to be a seperate file, I'm looking to combine them.

The problem is, I have no way of knowing where or what the y, z and other variable headers go.

So, I'd first have to find them, then concatenate them with tabs delimited, and then write them.

Cheers,
Janak
0 Kudos
Message 16 of 26
(2,082 Views)
Hello Sture,

I realized I was making some mistakes while converting your suggestions to code.

I have the correct version attached.

Just to diagnose what the extracted headers are, I'm writing to a .txt file just the headers. Seems like your program is able to extract the headers, but they're all jumbled up, having the first header twice etc. I can't seem to figure out how that is happening...

Would appreciate your input when you get a chance to have a look at the code. Maybe I am just not connecting the wires correctly.

Cheers,

Janak
0 Kudos
Message 17 of 26
(2,068 Views)
Oops, I forgot to include the code..here it is.


0 Kudos
Message 18 of 26
(2,069 Views)
Hi,
In my code the first header is returned twice from the first loop. Last element must be removed because at the end of the file first match pattern instance returnes -1 and then the second match pattern finds the first header again. This was taken care of in my version when I fed the headers to the second loop. Here is a screenshot of the frontpanel after running my code and the part of your code that should be modified (I wasn't able to save it in LV 8.0). I was not able to test your code.
 
/Sture
 

Message Edited by sture on 09-19-2007 10:01 AM

0 Kudos
Message 19 of 26
(2,059 Views)
OK, I did not notice that you have multiple sets in your file. You really should make a demo data file that only contains a few points per set so things are easier to see.
 
If I understand you correctly, you want to discard the first header, is that right? I am using it as filename for the xls file isntead, but you can easily modify that.
 
A quick minor adjustment of my code seems to do what you want, here's my assumption for an example datafile:
 
 
 
Here is a picture of the code that does it.
 
And here is the output what it would do to your data file. Close enough? 🙂
 
 
 
The VI and a small testfile is attached in a zip file (LabVIEW 8.0)

Message Edited by altenbach on 09-19-2007 09:06 AM

Message 20 of 26
(2,043 Views)