简体   繁体   中英

Converting file from python to exe

I've written a file that converts the delimiter in a CSV from format ',' to the ';'. I'm trying to convert this file from a .py to a .exe using auto-py-to-exe. Whilst this process does work and execute correctly clicking on the app does not do anything.

Am I missing something from the code? Perhaps an auto execute command?

# import necessary libraries
import pandas as pd
import os
import glob
  
  
# use glob to get all the csv files 
# in the folder
path = os.getcwd()
csv_files = glob.glob(os.path.join(path, "*.csv"))
  
  
# loop over the list of csv files
for f in csv_files:
      
    # read the csv file
    df = pd.read_csv(f, delimiter=',')
    df.to_csv(f, sep=';', index = False)
    

You should use argparse to provide the inpu# import necessary libraries

import pandas as pd
import os
import glob
import argparse
  
# use glob to get all the csv files 
# in the folder

parser = argparse.ArgumentParser()

# Adding optional argument
parser.add_argument("-i", "--InputPath", help="Input path files")
parser.add_argument("-i", "--OutPath", help="Out path files")


path = os.path.abspath(args.InputPath)
csv_files = glob.glob(os.path.join(path, "*.csv"))
  
  
# loop over the list of csv files
for f in csv_files:
      
    # read the csv file
    df = pd.read_csv(f, delimiter=',')
    df.to_csv(os.path.join(os.path.abspath(args.OutPath),f), sep=';', index = False) 

Then simply use the auto-py-to-exe to generate the exe.

Open the cmd to the place where the exe is there and use it accordingly.

CMD:
$ file.py -i "input path" -o "Out path"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM