cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
lwx228
Level VIII

How to extract specified data from a JSL hexadecimal file to a decimal file?

"Min1.dat" is a hexadecimal file.I have saved the data of the two tables in this DAT file.
For example, the original data of the file encoded as "113027" looks like this.

2020-11-11_13-42-32.png

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: How to extract specified data from a JSL hexadecimal file to a decimal file?

Your file might have Little Endian numbers. But without documentation of the file format, you can't be sure there is not another bit in the file that chooses Big vs Little representation. There can be a lot of bits that determine the shape of the binary data, and they can change if the program that generates the data runs with different options/data/environment.

 

Fun fact about Little Endian numbers: the 6502 processor in the ancient Apple II computer used Little Endian because it was faster to add two 2-byte numbers. The add of the low-order byte could be done in parallel with fetching the high-order byte that followed. The carry could then be propagated to the high order byte. 

Craige

View solution in original post

14 REPLIES 14
lwx228
Level VIII

Re: How to extract specified data from a JSL hexadecimal file to a decimal file?

Open "min1.dat" with "HxD x64.Exe to see the specific hexadecimal symbol.

 

JSL scripts written with Craige can also see this and display the same content.

b = Load Text File( "D:\0\Min1.dat", blob() ); // load your file

hex = Hex( b ); 

2020-11-11_13-47-41.png

 

lwx228
Level VIII

Re: How to extract specified data from a JSL hexadecimal file to a decimal file?

I have found the hexadecimal symbol shown in the first line of the file "113027" in HxD.exe.
The hexadecimal number for data 2010090931 is "B38DCF77" and the hexadecimal number for data 2010090932 is "B48DCF77"

2020-11-11_14-27-09.png

 

lwx228
Level VIII

Re: How to extract specified data from a JSL hexadecimal file to a decimal file?

How can use JSL to efficiently locate data, restore floating point data, and extract only the specified data?
How to extract all the data encoded "113027" directly from a hexadecimal file using JSL?

 

Thanks Experts!

lwx228
Level VIII

Re: How to extract specified data from a JSL hexadecimal file to a decimal file?

I used "Contains" to determine the location of the time data, but found it inefficient.

b = Load Text File( "D:\0\Min1.dat", blob() ); // load your file

hex = Hex( b ); 
last4hex = Right( hex, 8 ); 
num = Length( b );
last4blob = Blob Peek( b, Length( b ) - 4, 4 ); 

da1 = "B38DCF77";//B3~8D~CF~77
da2 = "B48DCF77";
off1 = Contains( hex, da1 );
off2 = Contains( hex, da2, -1 );
If( off1,
	hex = Substr( hex, off1, Length( hex ) )
);
If( off2,
	hex = Substr( hex, 1, off2 + 1 )
);


mat = Blob To Matrix( b, "int", 4, "big" ); 

2020-11-11_15-58-11.png

Craige_Hales
Super User

Re: How to extract specified data from a JSL hexadecimal file to a decimal file?

@lwx228  when I'm trying to extract information from a binary file without proper documentation, I have to think about what might happen next: the file format might change; I might not be around to support my hack; I might not actually understand the format. If the vendor that creates the file supplies tools for manipulating the file, you should use them. If the vendor documents the file format, you should use that documentation.

 

DangerZone.png

 

 

Craige
lwx228
Level VIII

Re: How to extract specified data from a JSL hexadecimal file to a decimal file?

Thanks for Craige's rigorous attitude.
My DAT data is free software data, in the window interface operation of the software can directly export TXT format data,
such as these two codes "113027" 、"123029"s data is derived in the software.
I just want to know how to make JMP directly read the data in the DAT file in this software,
so that there is no need to manually export the data in the software interface to save the TXT file to the hard disk, and then dual-use JMP to import the TXT file to the hard disk.
Thanks to the experts for their help.

vince_faller
Super User (Alumni)

Re: How to extract specified data from a JSL hexadecimal file to a decimal file?

Do you know if the software has command line options for doing that task?  I've seen some programs have CLI versions of some of their functions.

If you're lucky you might be able to do something like

 

Names default to here(1);
RP = Run Program(
	Executable( "DatFileCreator.exe" ),
	Options( { // all of these options are made up but I've seen programs have them before. 
		"-export 1" 
		, "-filepath 'C:\Fake\somefile.dat'"
		, "-exportpath 'C:\Fake\sometxtfile.txt"
	} ),
	ReadFunction( Function( {this}, Write( this << read ) ) )
);

dt = open("C:\Fake\sometxtfile.txt");

I would look through their command line arguments first.  Plus if they update their file format, they **should** update their export functionality and you won't have to rewrite it.  

 

 

Vince Faller - Predictum
lwx228
Level VIII

Re: How to extract specified data from a JSL hexadecimal file to a decimal file?

  • Thank you very much!

  • I didn't find

    "DatFileCreator.exe"

    file in my search.

I used to use similar software, but now the DAT data has changed and the software is no longer available.

2020-11-12_08-14-28.png

vince_faller
Super User (Alumni)

Re: How to extract specified data from a JSL hexadecimal file to a decimal file?

That's not a real software. I meant whatever software is outputting this data file.
Vince Faller - Predictum