LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting matrix and array from .dat file

hi all,

 

I need to know how to extract matrix and array from .dat file. I've been searching in code examples, but I couldnt find enough help.

In attachment I have a .dat file (can be opened with notepad), and I need to make intensity graph from x, y, and dc.

x values are between BEGIN_X and END_X

y values are between BEGIN_Y and END_Y

dc values are between BEGIN_DC and END_DC

This is what I try to do to read the data first. But when I need to read them all (far bigger index for FOR loop), it needs longer process time.

I think there might be alternative way which more efficient to load this data.

 

test.png

 

And then I need to get the values of x, y, and dc and build them into array and matrix, so I can put them into intensity graph.

Any helps are really appreciated.

 

Regards,

Yan.

0 Kudos
Message 1 of 9
(4,455 Views)

Hi!

The file shouldn't be read as a binary file, since it's a plain text.

Try using "Read from text file" vi and place all the content in a string (the file is not very large).

After that it's just a lot of parsing.

 

Regards,

Marco

0 Kudos
Message 2 of 9
(4,441 Views)

Hi marco,

 

1.With using read from text VI, I'm good to go? I think I need to use while loop instead FOR loop.

2.How to split two values with "tab" or "space" as their separator?

 

regards,

Yan.

0 Kudos
Message 3 of 9
(4,438 Views)

Simply use the Read From Spreadsheet File.

0 Kudos
Message 4 of 9
(4,433 Views)

Hi Dennis,

I would prefer to read the file a single string,

split it in the different sections and convert each sections in its matrix

 

Regards,

Marco

0 Kudos
Message 5 of 9
(4,415 Views)
Thats fine. Be sure to post your code to the rube goldberg thread when you are done.;)

Seriously, you duplicate what is already in the Read From Spreadsheet?
0 Kudos
Message 6 of 9
(4,409 Views)

Well, I don't like the absence of error out of "Read From Spreadsheet".

Moreover in this case the file is not a matrix,

but a sequence of 3 matrices and 2 vectors, so maybe it's worth a custom parser.
Marco

0 Kudos
Message 7 of 9
(4,405 Views)

hey guys,

 

this is what I got at the moment, I got the matrix and array out of the string. But I still have problem to spread them into the graph. 

 

tests.png

 

tests2.png

 

regards,

Yan.

Download All
0 Kudos
Message 8 of 9
(4,393 Views)

@MarcoMauri wrote:

Well, I don't like the absence of error out of "Read From Spreadsheet".

Moreover in this case the file is not a matrix,

but a sequence of 3 matrices and 2 vectors, so maybe it's worth a custom parser.
Marco


You could always modify that VI to bring the error out.  Just make sure to save it as your own VI someplace else...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 9
(4,389 Views)