I just had that problem myself... The question is old, but just in case, this is how I passed a context variable to a script in the data import handler:
<entity name="fileline" processor="LineEntityProcessor" url="${filelist.fileAbsolutePath}" format="text" transformer="TemplateTransformer,script:relatedItems">
<field column="dbname" template="${dataimporter.request.db_name}"/>
</entity>
the TemplateTransformer will add the parameter in a new field, before passing the augmented row to the script. Then in the script:
function relatedItems(row) {
var dbname= row.get("dbname");
var rawLine = row.get("rawLine");
....
}
you can access your extra variable this way. It seems somewhat convoluted, but that's the best I could find (that works!).