mmmmgggg

Get the output of FileWriteVar in human format

10 posts in this topic

Hello,

I am using FileWriteVar function to save in a file the value of an array. I have read in the documentation that this data is saved in binary format.

Can I see this data saved in the file in a human format? It doesn't matter using Wordpad, Excel, Internet online converter...

What's the decodification type of this file? For example, when you import a file in Excel it asks you if it is Unicode (UTF-8), European, Arabian...

Thank you for your help!

Share this post


Link to post
Share on other sites

Hi!

First of all, thank you for your response.

I have tried converting my binary file extracted from Sysmac in the webpage https://www.rapidtables.com/convert/number/binary-to-ascii.html (the binary file extracted with the function FileWriteVar) but I don't receive the response that I wanted.

The array that I want to save is a recipe, so I don't want to start concatening the elements and converting to string and things like this, because then, I want to use the same file with FileReadVar function to return to the past values in Sysmac.

 

ascii.PNG

Share this post


Link to post
Share on other sites

Convert the numbers to strings first if you want them human-readable

Capture.PNG

Edited by photovoltaic
Not enough coffee

Share this post


Link to post
Share on other sites

Just noticed your comment about strings... I don't see a way around it. You can covert from a string just as easily when properly parsed

Share this post


Link to post
Share on other sites

Hello! Thank you for your answer!

I was saying that I didn't want to convert to string directly from Sysmac because my variable is not a simple real; the variable that I'm writing in a file is a structute created  by me composed by strings, array of reals, array of booleans, booleans... But I understand that I can't open the output file of FileWriteVar in a human readable format unless I don't convert each element to a string.

Share this post


Link to post
Share on other sites

Consider using something like python's "struct" class to read your binary file and print the decoded results.  It can handle mixed structure types.

Share this post


Link to post
Share on other sites

Hi @pturmel

I see very interesting what are talking about python struct.

I have tried with some code samples found on Internet, but I don't get the result that I want.

For example with this code sample:

import struct
f = open(r"C:\Users\user\Desktop\RECIPE_001.dat", 'rb')
data = f.read()
data_unpack = struct.unpack('>f?7s', data)
print("data_unpack: ", data_unpack) 
f.close()

I get the next error:

struct.error: unpack requires a buffer of 12 bytes

Do you know what I need to write instead of '>f?7s' regarding to the file extracted from Sysmac?

Thank you!

Share this post


Link to post
Share on other sites

Suppose your recipe is in structure, you can use the function "AddDelimiter" to generated CSV line and put to text file.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now