Skip to content Skip to sidebar Skip to footer

Python Program Doesn't Write To Output Csv, Everything Else Seems To Work Correctly

from subprocess import check_output import csv, operator extinction_pct = operator.itemgetter('AOT 500','AOT 675','AOT 870','AOT 936','AOT 1020') with open('csv_export.csv')

Solution 1:

Using method provided here you can try using this.

import subprocess
proc = subprocess.Popen('cmd.exe', stdin = subprocess.PIPE, stdout = subprocess.PIPE)
stdout, stderr = proc.communicate('sbdart >> output.csv')

Make sure you put the full path of sbdart or navigate to the folder having sbdart or add location of sbdart to system path

There are a bunch of other methods in the link provided

Solution 2:

Working on Linux with python 3.5 Assume sbdart is executable and we have a file called output1.csvsbdart looks like this for our test case:

echo$1echo"$(cat $1)"

output1.csv is as follows:

&INPUTWLINF=0.250WLSUP=4.0WLINC=0.5IDAY=289ALAT= {row['Lat']}
ALON= {row['Long']}
IDATM=3ISALB=5IAER=5WLBAER= .500,.675,.870,.936,1.02WBAER=5*0.9GBAER=5*0.8TIME= {row['sama']}
QBAER= {','.join(extinction_pct(row))}
ZOUT=0.0,15.0/>>>import subprocess
>>> subprocess.check_output(['./sbdart output1.csv'],shell=True)
b"output1.csv\n&INPUT\nWLINF = 0.250\nWLSUP = 4.0\nWLINC = 0.5\nIDAY = 289\nALAT = {row['Lat']}\nALON = {row['Long']}\nIDATM = 3\nISALB = 5\nIAER = 5\nWLBAER = .500,.675,.870,.936,1.02\nWBAER = 5*0.9\nGBAER = 5*0.8\nTIME = {row['sama']}\nQBAER = {','.join(extinction_pct(row))}\nZOUT = 0.0,15.0\n/\n">>>

Post a Comment for "Python Program Doesn't Write To Output Csv, Everything Else Seems To Work Correctly"