reinato Posted November 30, 2005 Report Share Posted November 30, 2005 Hi, Does anybody know how to convert a binary file into ascii format? I have a sine waveform in binary and need to convert the data to ascii. The data is a single precision signed format. Quote Link to comment
Louis Manfredi Posted November 30, 2005 Report Share Posted November 30, 2005 Hi Reinato: Can't go through the whole thing, but the basic idea is as follows: 1) Read four bytes from a file. 2) Type cast the four bytes as a single. 3) Format the single into a string. I've left lots of details for you to work out-- put all this in a loop, with the file refnum wired to a shift register so you get more than just the first data point, might have to skip some header info in your file, might want to do something with the formatted data (Write to another file?), etc. but this should point you in the general direction. For some types of files, there might be an easier way to do this, but the approach I've shown above is pretty general, you should be able to adapt it to whatever your needs are-- some of the easier approaches might be less versatile. Hope this helps at least a little, Best Regards, Louis One more point-- Some possibility, depending on where the data came from, that you might have to reverse the order of the bytes after you read them & before you type cast them as single. If so, look under String Functions>Addition String Functions> reverse string. Louis Quote Link to comment
Mike Ashe Posted December 1, 2005 Report Share Posted December 1, 2005 Under the File I/O pallete you'll find the Binary File VIs pallete. You want the "Read From SGL File.vi", use that to read the data in, then write it back out with the first VI in the File I/O pallete: "Write To Spreadsheet File.vi" Two VIs. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.