Any method to restore garbled/distorted text file?

2 views (last 30 days)
Dear Sirs:
I got a very weird situation that highly needs your assistance. I appreciate your effort and time in advance.
I have a machine which produces a text file that records some information of the machine's working status such as, the coordinate of the drill head and the rotating speed used at that position. While we examine the text file, it appears to be unreadable because most of the contents are garbled. Please see the attached figure. http://ppt.cc/sA1I
As you can see some part of the file is readable; however many unrecognizable characters, which should be those numeric values we want.
Two reasons that I believe this problem should be solved by Matlab. First, I am sure this machine has many built-in matlab code inside for analysis purpose. Second, we have a .exe file, which is compiled by Matlab, can restore the garbled text file into arranged and readable format (the values of the coordinates are restored).
We desperately want to see the contents of this file by ourselves. Please kindly provide solution or idea or any direction for me to solve this issue.
Sincerely,
  2 Comments
Image Analyst
Image Analyst on 28 Aug 2013
You say "Second, we have a .exe file, which is compiled by Matlab, can restore the garbled text file into arranged and readable format" Do you really have that exe file already, one that can restore your file, or did you misstate that? Is it something you want to develop/build/make, not something you have already?
JY Su
JY Su on 29 Aug 2013
We really have the exe file already and I am sure it is compiled by matlab. However, this exe file is not mine. I want to read this file by myself. Thanks!

Sign in to comment.

Answers (3)

Iain
Iain on 28 Aug 2013
read the file as binary data, unsigned 8 bit integers.
When you have an unknown symbol, or for some reason you expect a known symbol to be a number, you should take that value, and try seeing what the value is using "typecast" eg.:
n = typecast(uint8([64 1]),'uint16')
n =
16385
n = typecast(uint8([0 0 0 0 0 0 64 1]),'double')
n =
1.1666e-302

JY Su
JY Su on 28 Aug 2013
Thanks for your timely reply!
I am not really familiar to binary format. Please allow me to ask more:
After I use fread('filename','unit8') to import this text file I got a very huge column (102645 by 1). In your opinion I should first identify the location of numbers? It is almost impossible for me since the file is very large and the structure of it is very complicated. There are many many heading and other notations.
Is that possible to read the text file and, somehow, convert it by functions of matlab, to another text file that are totally readable?
Thanks again!!
  3 Comments
Iain
Iain on 28 Aug 2013
If you know the format of the file, then yes, it's easy. You just read things, and change how you read them to get all the info the way you want it, then put it in a string and write it to file. Thats the easy part.
Your job is really to identify the format of the file. It is NOT an easy job unless you can add more information (like a complete description of the file).
Iain
Iain on 28 Aug 2013
I can't see those links - stupid work firewall settinsg.

Sign in to comment.


Walter Roberson
Walter Roberson on 28 Aug 2013
On a Unix type system, I would start with using "strings" on the file, and piping that into "uniq". Then I would go through the list of strings produced and remove the ones where it was clear that an extra character or two were spurious. The result should mostly be a set of keywords. Those keywords could be matched against in the text, and a binary value read after that point.
It appears to me that after 'coordinate' there are 8 binary bytes. Those might represent two four-byte values, or one eight-byte value. I do not know the byte ordering at this point; I would need to experiment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!