Subscribe Bookmark RSS Feed

Script template for creating jrp files from csv

artem_verbuk

Community Trekker

Joined:

Nov 9, 2014

Hi guys

I am new to JMP Pro and to its scripting language, as well as to those SAS forums.

If you think that I post my question in the wrong place - let me know and please excuse me,

My goal is to create a script that will:

open CSV file

create variability chart based on table from this file

save the result as JRP file

Now some details.

CSV file might be huge in row number. This file starts with line of column names. Lets assume that the complete path to this file is "PathToCSV".

I have a script that creates variability chart that I need. Lets assume that the text of this script is "ChartScript".

As a result I want to get a .JRP file that will contain both data from CSV file and chart, lets assume that the path to desired JRP file is "DesiredReportPath".

I know that column names in my script that creates chart are correct and those columns are present indeed in CSV file.

More details:

Actually I am writing some C# application that automates the process of test log parsing. It does a lot of (irrelevant for JMP) things.

We have some environment that creates a lot of csv files with know schemes.

We have some specialists that know to open those files in JMP Pro and to create the charts that they need.

So those people can give me precise scripts for those charts. They have different charts for different schemes of CSV.

I am merging those csv with same schemes in my app, and then I want to use JMP interop to run the script that I want to construct.

I will run the different script for each merged CSV file. So I need to create a template for the script.

Question: What would be the script to do what I want?

I assume that it has the following construction:

X1 PathToCSV X2 ChartScript X3 DesiredReportPath

Where X1 opens CSV file and creates some data table,

X2 opens new tab(?) for chart and creates it

X3 saves all work to desired path

Regards,

Artem;

3 REPLIES
Byron_JMP

Staff

Joined:

Apr 26, 2012

I suspect this answer is a gross over simplification, but just opening a CSV (assuming the data is well structured) generating a report (JMP calls output reports), journaling the result and saving the journal isn't terribly complex.

JMP writes most of this for you. Just capture the scripts from the Source script in the opened file, and the report script from the variability report. Formatting the CSV prior to opening it in JMP is the hard part.

I hope this helps,

Byron

example: (past this in a JMP script window

path=get default directory();//gets dir of where this script is saved

//JMP writes this statement when it opens the file. Check the Source script in a JMP table from a CSV

dt=Open(

  "C:\Program Files\SAS\JMPPRO\11\Samples\Import Data\Book1.csv",

// this file might be at a different location on your installation.

  columns(

  Column( "1", Numeric, nominal, Format( "Best", 10 ) ),//I made this col nominal for the example

  Column( "2", Numeric, nominal, Format( "Best", 10 ) ),//I made this col nominal for the example

  Column( "3", Numeric, Continuous, Format( "Best", 10 ) )

  ),

  Import Settings(

  End Of Line( CRLF, CR, LF ),

  End Of Field( Comma, CSV( 1 ) ),

  Strip Quotes( 0 ),

  Use Apostrophe as Quotation Mark( 0 ),

  Scan Whole File( 1 ),

  Treat empty columns as numeric( 0 ),

  CompressNumericColumns( 0 ),

  CompressCharacterColumns( 0 ),

  CompressAllowListCheck( 0 ),

  Labels( 1 ),

  Column Names Start( 1 ),

  Data Starts( 2 ),

  Lines To Read( "All" ),

  Year Rule( "20xx" )

  )

);

//jmp wrote the script for this variability chart. Just copy the script from the report

vc=dt<<Variability Chart(

  Y( :Name( "3" ) ),

  X( :Name( "1" ), :Name( "2" ) ),

  Max Iter( 100 ),

  Conv Limit( 0.00000001 ),

  Number Integration Abscissas( 128 ),

  Number Function Evals( 65536 ),

  Analysis Type( Name( "Choose best analysis (EMS REML Bayesian)" ) ),

  Std Dev Chart( 0 )

);

jvs=vc<<journal ;

//save the journal "jvs" to path, concatinated to, the file name

jvs << save journal( path || "testJRN.jrn" );

//or other convenient file types

jvs << save pdf( path || "testPDF.pdf" );

jvs << save picture( path || "testPNG.png", png );

jvs << Save Interactive HTML( path || "testHTML.htm" );

jvs << Save MSWord( path || "testDOC.doc" );

artem_verbuk

Community Trekker

Joined:

Nov 9, 2014

Thanks for the answer, Byron!

The script you gave is almost what I need.

However, there are some things that I miss/don't understand.

I think that I have a problem with the following two lines:

jvs=vc<<journal ;

jvs << save journal( "C:/testJRN.jrn" );


First of all - are they connected? Meaning, if I want to save only an image of the variability chart, should I still have the

"jvs=vc<<journal ;" line in my template?


And I know for sure, that I will need only two options (So I need two templates, or template with additional parameter):

1 - Save image of created chart

2 - Save something that

  • contains all data from CSV
  • contains the created chart
  • allows further working with two above

So, the journal is the correct option for the second? Or "report"?

May be the last string should be something like:

jsv<< save report("C:/testReport.jrp");


Regards,

Artem


Byron_JMP

Staff

Joined:

Apr 26, 2012

In this case vc is the variability chart, its the variable (handle) for addressing the report window.

vc<<journal,  simply journals the report window.

In the example I saved the journal "jvs" as several file types. We could have just saved "vc" as one of those file types. 

Sending multiple reports to a journal and then saving the journal is convenient when I don't want to spend any time building a prettier report window, e.g. application builder.

There is so much flexibility with JSL that you can really build almost anything you can imagine.