About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Last updated: Feb 11, 2025
With the Extension Export node, you can run R or
Python for Spark scripts to export data.
Python for Spark example
import modeler.api
stream = modeler.script.stream()
node = stream.create("extension_export", "extension_export")
node.setPropertyValue("syntax_type", "Python")
python_script = """import spss.pyspark.runtime
from pyspark.sql import SQLContext
from pyspark.sql.types import *
cxt = spss.pyspark.runtime.getContext()
df = cxt.getSparkInputData()
print df.dtypes[:]
_newDF = df.select("Age","Drug")
print _newDF.dtypes[:]
df.select("Age", "Drug").write.save("/opt/IBM/SPSS/ModelerServer/Cloud/demos/Drug.json", format="json")
"""
node.setPropertyValue("python_syntax", python_script)
R example
node.setPropertyValue("syntax_type", "R")
node.setPropertyValue("r_syntax", """write.csv(modelerData, "/opt/IBM/SPSS/ModelerServer/Cloud/demos/ export.csv")""")
properties |
Data type | Property description |
---|---|---|
|
R Python | Specify which script runs: R or Python (R is the default). |
|
string | The R scripting syntax to run. |
|
string | The Python scripting syntax to run. |
|
|
Option to convert flag fields. |
|
flag | Option to convert missing values to the R NA value. |
|
flag | Option to convert variables with date or datetime formats to R date/time formats. |
|
|
Options to specify to what format variables with date or datetime formats are converted. |
Was the topic helpful?
0/1000