python - IOError: [Errno 2] No such file or directory:'ux_source_2850.txt -


i trying convert file format python code requires 3 arguments input file, output file , percentage value. call python function in shell script , works fine first time, doesn't work second time. error "ioerror: [errno 2] no such file or directory: 'ux_source_2850.txt". pretty sure file in directory. can please me out. also, wondering if there way call python function, compiled c function, can execute function several arguments.

#!/usr/bin/env python def convertfile(file1,file2,percentage):    open(file1, "r+") infile, open(file2, "w+") outfile:     outfile.write('lon lat ve vn se sn cen site ref\n')     line in infile.readlines():       line = line.strip()       new_line=line + " "+percentage+" "+percentage+" "+'0.05 stat(0,0) test1'+'\n'       outfile.write(new_line) file1=raw_input()                                                               file2=raw_input()                                                               percentage=raw_input()                                                          convertfile(file1,file2,percentage)  #!/bin/bash infile1=ux_source_$j.txt                                                        outfile1=ux_$j.txt                                                              percentage1=`sort biggest_z_amp  | tail -1 | awk '{print $1*2e4}'`              ../convertfile.py<<!                                                            $infile1                                                                        $outfile1                                                                       $percentage1                                                                    !                                                                               infile2=uy_source_$j.txt                                                        outfile2=uy_$j.txt                                                              ../convertfile.py<<!                                                            $infile2                                                                        $outfile2                                                                       $percentage1                                                                    !               

it problem in shell script, not python script. make sure have no trailing spaces in lines give input python script.

better still, use:

file1 = raw_input().strip() file2 = raw_input().strip() 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -