01-22-2013 04:13 AM
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.
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.
01-22-2013 07:00 AM
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
01-22-2013 07:59 AM
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.
01-22-2013 09:14 AM
Simply use the Read From Spreadsheet File.
01-23-2013 01:01 AM - edited 01-23-2013 01:02 AM
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
01-23-2013 01:16 AM
01-23-2013 01:38 AM
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
01-23-2013 01:00 PM
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.
regards,
Yan.
01-23-2013 01:05 PM
@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...