LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing coordinates to a binary file

Hey so I'm writing a program that looks at an image and every loop iteration takes 1 specific x,y coordinate (as well as the time), builds an array, and saves it to a file. I would like to do it as efficiently as possible and so I've been lead to believe binary is the most efficient way to store data. I dont get any errors when I run my program, has 3 inputs wired to a build array, and then passes the array to the save file. But I'm having trouble reading it. I'm not really familiar with programming.

What would I need to wire to the "read from binary file" to get the array back, basically reversing the process? 

0 Kudos
Message 1 of 5
(3,089 Views)

EDIT: I've managed to at least get the numbers back out of the binary file..but in the end I would really like to be able to put them in a spreadsheet for easy viewing. Wiring the output data terminal to Write to spreadsheet gives me an excel file which has all my data in a single row. For example, x,y,time,x,y,time,x,y,time..etc. How would I invert the data to get it into 3 columns?

0 Kudos
Message 2 of 5
(3,083 Views)

You are only showing the write part, and you don't even have the array wired to the Write Binary File function, so I don't see how you can expect anything to be written to file.

 

As for efficiency: define efficiency. Efficiency of what? Memory usage? Disk space? Execution? As for memory usage, if you're building an array then you are continually growing an array, which will require frequent memory allocations as the array grows. How much data are you trying to save? As for disk space, pure binary may be more "efficient" - it depends on the data that you're trying to save. For example, if your data consists of an array of DBLs, each DBL is 64 bits (8 bytes). If the numbers are such that you only need 4 characters plus one for the decimal point, then a text version would require up to 5 bytes per number (I'm assuming plain ol' ASCII here, not Unicode) as opposed to 8 bytes per number for binary.

0 Kudos
Message 3 of 5
(3,080 Views)

Follow-up: You posted the second message while I was creating my reply.

 

As for your follow-up question, the Write to Spreadheet File has a "transpose" input. Did you look at the Help for that function? Are you wiring a 1D array or a 2D array?

0 Kudos
Message 4 of 5
(3,077 Views)

Haha sorry about the unclear information. I was in a bit of a rush today to get this done, I figured posting for help while browsing examples and google would hopefully lead me to the answer and yes I eventually got to the transpose function so thank you! The data was originally the x and y coordinates of a point in an image acquired from a camera. And putting "write to spreadsheet" inside of my acquisition loop was actually cauing me to lose about 70 FPS(half :\) on my camera. So I suppose its processing power I was saving? Because once I got the binary file save in, everything was back to normal. Thanks again for the speedy reply!

 

Edit: I was wondering why I didn't get the email about the reply and apparently it's cause another person I work with was logged into the forums haha. But same person 

0 Kudos
Message 5 of 5
(3,062 Views)