cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
lala
Level VIII

Can JMP compute the MD5 value for each row of text in the specified column?

txt
zzJXKxOYK2w2I000163798053859
eaimGDAVK2w2I000163798053859
wOSVvvNQK2w2I000163798053859
WXHmhViTK2w2I000163798053859

Thanks!

2024-04-11_12-18-25.png

6 REPLIES 6
jthi
Super User

Re: Can JMP compute the MD5 value for each row of text in the specified column?

Scripting Index does give fairly good example

Names Default To Here(1);
Hex(/* make it printable */ Blob MD5(/* get the hash */
		Load Text File(/* a file from the samples */
			"$SAMPLE_IMPORT_DATA/animals.txt",
			BLOB/* the result is a BLOB, not a string */
		)
	)
) == "763D3C9F5F3E92951B3A3DC965084DAC" /* benchmark hash value */ /* the result is 1 if the benchmark matches */
;

with slight modification

Hex(Blob MD5(Char To Blob("mytext")));
-Jarmo

Re: Can JMP compute the MD5 value for each row of text in the specified column?

Using the Python Integration in JMP 18.  The code here opens 'Big Class' adds a 'cksum' column then does the md5 checksum on the 'name' column, filling in the data table rows as you go along.

 

import jmp
import hashlib

dt = jmp.open(jmp.SAMPLE_DATA + 'Big Class.jmp')
dt.new_column('cksum', jmp.DataType.Character)

for x in range( dt.nrows ):
    dt['cksum'][x] = hashlib.md5( dt['name'][x].encode('utf-8' ) ).hexdigest()

 

Big Class-md5.png

lala
Level VIII

Re: Can JMP compute the MD5 value for each row of text in the specified column?

Thanks!

  • Unfortunately, JMP 18 hasn't had a chance to be tried yet.

Looking forward to it.

lala
Level VIII

Re: Can JMP compute the MD5 value for each row of text in the specified column?

Can this python code be changed from multiple lines to one line?
For example:

import jmp ;import hashlib

dt = jmp.open(jmp.SAMPLE_DATA + 'Big Class.jmp');dt.new_column('cksum', jmp.DataType.Character)

Thanks Experts!

Re: Can JMP compute the MD5 value for each row of text in the specified column?

Yes you can.

 

One of Python's central design goals is ensuring code readability.  That's why there are no begin / end block control characters such as used by C / C++ / Java. {  }  Instead Python forces use of indentation levels to signify scoping.  As a developer that has had to maintain my own code (or worse someone else's code), months or years later, I prefer making code easy for me to read.   The combination on a single line only saves a single character in memory, <CRLF> vs ';'  But if you have any spacing around the ';' then you are not saving memory and reducing clarity. 

 

The choice is entirely yours.

Craige_Hales
Super User

Re: Can JMP compute the MD5 value for each row of text in the specified column?

I wish for a knowledge wiki. And a way to promote examples like this one, and make it cross-referenced by Python, MD5, and Data table.

And I like your compromise dark/light theme; between that and the drop shadow, it really looks good with the high contrast black/white.

Craige