Page 1 of 1

execute command to launch a python csv to xml script

Posted: Sun Jul 03, 2011 5:47 pm
by antifish
Hi,



I am running PowerSwitch 10 on Mac OS 10.6.

I try to run a python script with the "execute command" tool to convert csv files to xml.

the python script looks like that:



#! /usr/bin/env python



import sys

import csv



csv.register_dialect('custom',

delimiter=',',

doublequote=True,

escapechar=None,

quotechar='"',

quoting=csv.QUOTE_MINIMAL,

skipinitialspace=False)



with open(sys.argv[1]) as ifile:

data = csv.reader(ifile, dialect='custom')

print ""

for record in data:

print " "

for i, field in enumerate(record):

print " " % i + field + "" % i

print " "

print ""



The script itself works fine if run "manually" in the terminal application.

I now want switch to run the script..

I configured the "execute command" flow element with these properties:



command or path: /bin/bash

arguments: python Volumes/HD/Desktop/csv2xml.py "%1" > "%2"

Output: file at path

Output extension: XML (*.xml)



But i never got any file written into my output folder. The message given by the "execute command" is that: "File '_00023_input.csv' was sent to null; it will be deleted when the entry point finishes"



Can somebody please tell me what i am doing wrong here?

execute command to launch a python csv to xml script

Posted: Mon Jul 04, 2011 4:17 pm
by bens
Can you try changing the arguments to: -c 'python Volumes/HD/Desktop/csv2xml.py "%1" > "%2"'



If this doesn't work, I would suggest wrapping the whole thing into a bash script, and using that in the command property.

execute command to launch a python csv to xml script

Posted: Tue Jul 05, 2011 4:54 pm
by dkelly
Hello, I've written a 100% Switch Javascript CSV->XML conversion if you are interested.



Dwight Kelly

Apago, Inc.

dkelly@apago.com

execute command to launch a python csv to xml script

Posted: Tue Jul 05, 2011 5:39 pm
by antifish
Hello, I've written a 100% Switch Javascript CSV->XML conversion if you are interested.


This would be an even better solution. It would be great if you can share it with me!



Can you try changing the arguments to: -c 'python Volumes/HD/Desktop/csv2xml.py "%1" > "%2"'


I tried that, but sadly it didn't change anything.

execute command to launch a python csv to xml script

Posted: Tue Aug 02, 2011 9:53 am
by fcanneviere
hello,



excuse me for my poor english because i'm french.

I have a full flow in python.

that's work very well

Try to use the absolut path for python