<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Best method to get a python object into JMP in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15163#M14027</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for looking at it, and good question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you are fighting the windows command line behavior with embedded blanks in file names.&amp;nbsp; In a DOS box, you'd use quotation marks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="quotes.png" class="image-1 jive-image" src="https://kvoqx44227.lithium.com/legacyfs/online/10408_quotes.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the escaping gets a little ugly, but here it is in JSL:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_macro_quote jive_text_macro"&gt;&lt;P&gt;runprogram(executable("cmd.exe"),&lt;/P&gt;&lt;P&gt;&amp;nbsp; options({"/C","dir \!"c:\Users\chales\Saved Games\!""}), &lt;/P&gt;&lt;P&gt;&amp;nbsp; readfunction("text"))&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't have python here at the office, but I anticipate it will have the same behavior.&amp;nbsp; It gets worse if you need to embed quotation marks; another project I'm working on used \" as described in one of the answers in &lt;A href="http://stackoverflow.com/questions/7760545/cmd-escape-double-quotes-in-parameter" title="http://stackoverflow.com/questions/7760545/cmd-escape-double-quotes-in-parameter"&gt;http://stackoverflow.com/questions/7760545/cmd-escape-double-quotes-in-parameter&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you get to choose the path names for your projects, leaving out the blanks will make it easier.&amp;nbsp; If you have a file picker, you need to allow for them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Nov 2015 21:41:28 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2015-11-09T21:41:28Z</dc:date>
    <item>
      <title>Best method to get a python object into JMP</title>
      <link>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15158#M14022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have some python code that can generate about 3 gb of data over 15 minutes.&amp;nbsp; It is currently streaming the data to a text file as a "column" value1|value2|value3.. line and then does some post processing to convert the whole text file into a csv that jmp can open.&amp;nbsp; The csv file can have up to ~30k columns and 100 to 10k rows after it splits the values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To make the data get to JMP faster, I would like to stream the text data directly from the memory of the python session into a jmp session.&lt;/P&gt;&lt;P&gt;I have tried some ole automation using pycom but it seems that the calls to pycom are very slow which makes it hard to iterate on each line and update the correct row for the couple of values that get produced in that "line".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there another way? sqlite memory table? JSL socket?&amp;nbsp; JMP python API?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 18:34:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15158#M14022</guid>
      <dc:creator>keith_a_kraft</dc:creator>
      <dc:date>2015-11-04T18:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Best method to get a python object into JMP</title>
      <link>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15159#M14023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you could move IEEE floating point data or integers between python and JMP using &lt;A href="https://docs.python.org/3/library/struct.html" title="https://docs.python.org/3/library/struct.html"&gt;7.1. struct — Interpret bytes as packed binary data — Python 3.5.0 documentation&lt;/A&gt; on the python end and blobToMatrix on the JMP end.&amp;nbsp; No conversion between binary and character and back to binary will speed it up, a lot. Use a file or a socket between them.&amp;nbsp; Are they on the same machine? that will make it a little easier.&amp;nbsp; Not the same machine? might not be IEEE floating point...&amp;nbsp; Character data would need different handling, but should be easier than numeric.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Nov 2015 20:29:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15159#M14023</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2015-11-04T20:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: Best method to get a python object into JMP</title>
      <link>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15160#M14024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a complete example that runs in about 2 seconds for 1,000,000 doubles:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the python code builds an array of doubles, makes a binary string of bytes, and writes the bytes to stdout.&amp;nbsp; You could use a file if you like, just make sure it is opened in binary mode (wb).&amp;nbsp; The "&amp;gt;" at the beginning of the pack format means "big endian".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"generate.py"&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_macro_quote jive_text_macro"&gt;&lt;P&gt;import array&lt;/P&gt;&lt;P&gt;import struct&lt;/P&gt;&lt;P&gt;import math&lt;/P&gt;&lt;P&gt;import sys&lt;/P&gt;&lt;P&gt;# windows python messes up binary newlines...unless...&lt;/P&gt;&lt;P&gt;if sys.platform == "win32":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import os, msvcrt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)&lt;/P&gt;&lt;P&gt;bigmat = array.array("d")&lt;/P&gt;&lt;P&gt;for x in range(0,1000000):&lt;/P&gt;&lt;P&gt;&amp;nbsp; bigmat.append(math.sqrt(x))&lt;/P&gt;&lt;P&gt;# %s is replaced by "1000000" ... d is for double precision 8 bytes each&lt;/P&gt;&lt;P&gt;binary = struct.pack("&amp;gt;%sd" % len(bigmat), *bigmat)&lt;/P&gt;&lt;P&gt;# print len(binary) # 8000000 bytes&lt;/P&gt;&lt;P&gt;sys.stdout.write(binary)&lt;/P&gt; &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the JSL uses runProgram to run the python program, and reads a blob back from the stdout.&amp;nbsp; BlobToMatrix specifies "big" to match the big endian data.&amp;nbsp; You could use LoadTextFile( ...BLOB ) instead of runProgram if you make the python program run separately and write a file.&amp;nbsp; You'd still need blobToMatrix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"fetch.jsl"&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_macro_quote jive_text_macro"&gt;&lt;P&gt;x = runprogram(executable("C:\Python27\python.exe"),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; options("C:\Users\User\Desktop\pythonExample\generate.py"),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; readfunction("blob"));&lt;/P&gt;&lt;P&gt;xx = blobToMatrix(x,"float",8,"big");&lt;/P&gt;&lt;P&gt;// verify...&lt;/P&gt;&lt;P&gt;ok="good";&lt;/P&gt;&lt;P&gt;for(i=0,i&amp;lt;nrows(xx),i++,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if( xx[i+1] != sqrt(i), ok="bad")&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;show(ok);&lt;/P&gt; &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ok = "good";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/2374427/python-2-x-write-binary-output-to-stdout" title="http://stackoverflow.com/questions/2374427/python-2-x-write-binary-output-to-stdout"&gt;http://stackoverflow.com/questions/2374427/python-2-x-write-binary-output-to-stdout &lt;/A&gt;​ had the answer for the binary newline issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 03:53:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15160#M14024</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2015-11-09T03:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Best method to get a python object into JMP</title>
      <link>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15161#M14025</link>
      <description>&lt;P&gt;&lt;A href="https://community.jmp.com/people/Craige@JMP" target="_blank"&gt;Craige@JMP&lt;/A&gt;​&lt;/P&gt;
&lt;P&gt;I was having an issue with Run Program that seemed to do with the options and file name I use for Run Program.&amp;nbsp; If I use pick file(), it crashes for me.&amp;nbsp; Or if I hard code a directory with a space in it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have any suggestions to make this dynamic?&amp;nbsp; Using JMP 12.0.1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;f = pick file();
 
 
//doesn't work
x = runprogram(executable("C:\Python34\python.exe"),
options(f),
readfunction("blob")
);
 
//doesn't work
x = runprogram(executable("C:\Python34\python.exe"),
options("/C:/Users/User/Desktop/generate.py"),
readfunction("blob")
);
 
//doesn't work
x = runprogram(executable("C:\Python34\python.exe"),
options("'C:/Google Drive/Work/Scripting/generate.py'"),
readfunction("blob")
);
 
//works
x = runprogram(executable("C:\Python34\python.exe"),
options("C:/Users/User/Desktop/generate.py"),
readfunction("blob")
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 20:29:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15161#M14025</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2017-10-27T20:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Best method to get a python object into JMP</title>
      <link>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15162#M14026</link>
      <description>&lt;P&gt;Very cool way to use Run Program&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have the solution but this works in JMP 12.1 on Mac&lt;/P&gt;
&lt;P style="margin: 0px; font-size: 17px; line-height: normal; font-family: Courier; color: #032ce4;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0px; font-size: 17px; line-height: normal; font-family: Courier; color: #032ce4;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;f = Pick File();
x = RunProgram(
    executable("/usr/bin/python"),
    options(f),
    readfunction("blob")
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P style="margin: 0px; font-size: 17px; line-height: normal; font-family: Courier;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&lt;SPAN style="color: #011993;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 27 Oct 2017 20:30:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15162#M14026</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2017-10-27T20:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Best method to get a python object into JMP</title>
      <link>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15163#M14027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for looking at it, and good question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you are fighting the windows command line behavior with embedded blanks in file names.&amp;nbsp; In a DOS box, you'd use quotation marks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="quotes.png" class="image-1 jive-image" src="https://kvoqx44227.lithium.com/legacyfs/online/10408_quotes.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the escaping gets a little ugly, but here it is in JSL:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_macro_quote jive_text_macro"&gt;&lt;P&gt;runprogram(executable("cmd.exe"),&lt;/P&gt;&lt;P&gt;&amp;nbsp; options({"/C","dir \!"c:\Users\chales\Saved Games\!""}), &lt;/P&gt;&lt;P&gt;&amp;nbsp; readfunction("text"))&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't have python here at the office, but I anticipate it will have the same behavior.&amp;nbsp; It gets worse if you need to embed quotation marks; another project I'm working on used \" as described in one of the answers in &lt;A href="http://stackoverflow.com/questions/7760545/cmd-escape-double-quotes-in-parameter" title="http://stackoverflow.com/questions/7760545/cmd-escape-double-quotes-in-parameter"&gt;http://stackoverflow.com/questions/7760545/cmd-escape-double-quotes-in-parameter&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you get to choose the path names for your projects, leaving out the blanks will make it easier.&amp;nbsp; If you have a file picker, you need to allow for them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 21:41:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/15163#M14027</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2015-11-09T21:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Best method to get a python object into JMP</title>
      <link>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/46436#M26468</link>
      <description>&lt;P&gt;Craig,&lt;/P&gt;&lt;P&gt;Not much help, but it also works this way in JMP 13.&amp;nbsp; Have to ask JMP support...Maybe it will get fixed in JMP 14&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 19:47:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Best-method-to-get-a-python-object-into-JMP/m-p/46436#M26468</guid>
      <dc:creator>vt_sailor</dc:creator>
      <dc:date>2017-10-26T19:47:44Z</dc:date>
    </item>
  </channel>
</rss>

