Skip to main content
After reviewing the five steps in our best practices recommendations in the previous lesson to ensure everything is running properly, you can batch process your workflow or integrate with external software using Python scripts or other languages. You can start with our Python example or Matlab example to set up your script for calling nTop and modify them to pass your input lists in a For loop.

nToPY

The ‘ntopcl.py’ file, available for download below, is a Python module our engineer created to make simple commands for the nTop Command Line interface without the text and shell submission. The examples in this course do not use this module, but an example script and files are included in the downloadable zip file to explore if you would like to use them. You can type in each of the three functions with the inputs, and it will run nTop. Here is how to use them:
  1. Place the ‘ntopcl.py’ file in your working directory
  2. Put import ntopcl at the top of your Python script
  3. Then you can use one of the functions with appropriate inputs, explained below:
Example File: 330_8_1 nToPy.zip Report File Issue

ntopcl.numtext(GUI, SAVE, INPUTS, NTOP FILE)

Runs nTop with a series of inputs that are either scalar or text type using Method 1 explained in the “Running a Command” lesson. The inputs include: GUI: When set to 1, the nTop graphical user interface will open up. You can use this to check that all of the inputs are passing correctly into the nTop file, and it’s running as you expect it. Otherwise, set to 0 to run headlessly.  SAVE: When set to 1, the inputs passed into the nTop Notebook will be saved into the nTop file. Otherwise, set to 0.  INPUTS: Array of inputs, as many as are in the Notebook Inputs section, that are either text strings or scalar numbers, defined in the following format. Numbers will maintain 6 decimal points. The input order should match what’s in the nTop Notebook Input section. It’s good practice to match the input names between Python and nTop, but not mandatory.  For example:
Inputs = {  
  "Name" : Current_Directory,  
  "Length" : 4.000,  
  "Width" : 5.000,  
  "Height" : 3.000  
}
NTOP FILE: Name of nTop file including the ‘.ntop’ file extension, in the same directory.

ntopcl.jsontemplate (NTOP FILE)

Creates input and output JSON files in the working directory, based on what is in the Inputs and Output section of the Notebook. Equivalent to typing the -t argument into the command line for Method 2 explained in the “Running a Command” lesson. The only input is: NTOP FILE: Name of nTop file including the ‘.ntop’ file extension, in the same directory.

ntopcl.json (GUI, SAVE, INPUT JSON FILE, OUTPUT JSON FILE, NTOP FILE)

Runs nTop with inputs based on a JSON file using Method 2 explained in the “Running a Command” lesson. The inputs include: GUI: When set to 1, the nTop graphical user interface will open up. You can use this to check that all of the inputs are passing correctly into the nTop file, and it’s running as you expect it. Otherwise, set to 0 to run headlessly.  SAVE: When set to 1, the inputs passed into the nTop Notebook will be saved into the nTop file. Otherwise, set to 0.  NPUT JSON FILE: Name of JSON file with inputs that control the inputs into the nTop Notebook. OUTPUT JSON FILE: JSON file name that will be made or overwritten when nTop runs. The file will contain information about the block in the Output section of your nTop Notebook. NTOP FILE: Name of nTop file including the ‘.ntop’ file extension, in the same directory.