python-shell icon indicating copy to clipboard operation
python-shell copied to clipboard

Passing filename dynamically #8

Open sundaresanab opened this issue 7 years ago • 4 comments

Hi,

We are trying to pass the filename dynamically in 'make_clustergrammer.py', each call the text file name will be different.

fileName = sys.argv[1:]
loadFile = ''.join(fileName)
decoded_string = bytes(loadFile, "utf-8").decode("unicode_escape") # python3 
# load matrix tsv file
tempassign = decoded_string.replace('\"','')
confilename = 'txt/' + tempassign  + '.' + 'txt'
print(confilename )
net.load_file(confilename)

Error which I'm getting as follows,

FileNotFoundError: [Errno 2] No such file or directory: 'txt/.txt'

1 . assigned variable is empty 2. I m communicating python script from nodejs.

Pls help me out, i got stuck with this more than a week.

Really, this clustergrammer is what needed exactly for our project.

We using MEAN(MongoDb, ExpressJS, Angular 4, NodeJs).

Actual prob is when i assign the argv[1:] to a variable and use that variable as parameter for 'net.load_file('filename')', it is empty.

Hard code: capture

capture1

capture 2

Thanks in advance.

sundaresanab avatar May 04 '18 10:05 sundaresanab

Are you able to print the fileconname on line 15 in your second screenshot?

san-j-vig avatar May 12 '18 16:05 san-j-vig

Yes, it is printing the value. But when i pass it as argument in next line, it is empty.

sundaresanab avatar May 14 '18 07:05 sundaresanab

Add these lines above net.load_file():

print (fileconname) sys.exit()

And post the output here.

san-j-vig avatar May 14 '18 16:05 san-j-vig

Pls find the code and result screenshots,

Note 1: sys.exit( ) terminating the script, i need to load the file and write json file further. I think in order to see the exact line you asking me to terminate the script.

Note 2: Actually before executing the python script, i m creating the txt file in "D" drive.

result code

Thanks in advance.

sundaresanab avatar May 15 '18 08:05 sundaresanab