I'm trying to run an Executable Command configurator with a Python script that will convert .CSV to .XML In this Python script it call for the input file and the output file. If I hard code that to file and paths it works running in Switch. But if I replace those filepaths with the Switch variables "$1" and "$2" it will not work. I've tried with "%1" and "%2" as well and variants of those two but it never works.
I get the error from Switch that the Python Script can't find the input file.
I suspect that I have to make the Switch variables to Python variables for this to work but I don't know how to do that.
Python script looks like this, I have tried to make Python variables here

Code: Select all
#!/usr/local/bin/python
import csv
import sys
inputfile = "$1"
outputfile = "$2"
csv.register_dialect('custom',
delimiter=',',
doublequote=True,
escapechar=None,
quotechar='"',
quoting=csv.QUOTE_MINIMAL,
skipinitialspace=False)
with open(inputfile) as ifile:
data = csv.reader(ifile, dialect='custom')
sys.stdout=open(outputfile, 'w')
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
print "<csv>"
for record in data:
print " <row>"
for i, field in enumerate(record):
print " <col%s>" % i + field + "</col%s>" % i
print " </row>"
print "</csv>"
Code: Select all
#!/bin/bash
python /shellscripts_for_switch/csv2xml.py "$1" "$2"
I have tried another CLI script that does this job but the Python script has more control over what ends up in the XML, the other one just converts. Its called "csvprintf"
All this is for a flow that will make business cards with QR code and names collected from an XLSX file. I got inspired from the Summer camp on QR-codes.
It looks like this:

Thanks
Jan