0

I am using VBScript in my code to convert each sheet of a given excel file into a CSV file. I have tried other methods such as using pandas but they are comparatively slow and the vb script method performs pretty well when I run the script.

The only problem I am facing is that when I use auto-py-to-exe to convert my script into an exe for a client, the VBScript is executed automatically when auto-py-to-exe is compiling the code.

I have searched a lot but couldn't find anything similar to my problem. Any help in this regard would be much appreciated. Thanks!

The snippet where I call cscript is given below:

    if not os.path.exists('./Temp'):
        os.mkdir('./Temp')
    s = time.time()
    temp = './Temp'
    call(['cscript.exe', os.path.join(os.getcwd(),'ExcelToCsv.vbs'), filename, temp])
    e = time.time()
    print("Time taken to convert excel sheets to CSV files: ", e - s)
Dima Chubarov
  • 16,199
  • 6
  • 40
  • 76

1 Answers1

0

Well, maybe this will sound stupid, but have you tried replacing call function within os.system function? I have done something like that many times and it worked perfectly. This is the first time i see this error.

  • Thank you for your suggestion. It is my first time using either of subprocess or os.system function. I tried using os.system after your suggestion but I guess I am not passing the parameters the right way. I tried ``` cmd = f"cscript.exe {os.path.join(os.getcwd(),'ExcelToCsv.vbs')} {filename} {temp}" os.system(cmd)``` but I guess it makes the parameter too long and the vbscript throws an error. – Muhammad Mutahhar Bin Muzaffar Sep 25 '20 at 19:47
  • What is the error that vbscirpt is throwing? It seems unlikley that list of parameters is too long. Maybe you should put your path in quotation marks so it looks like this: `cmd = f"cscript.exe \"{os.path.join(os.getcwd(),'ExcelToCsv.vbs')}\" {filename} {temp}"` – MrSquidward Sep 25 '20 at 21:56