0

I have python script , i want to change this simple script to .exe file with user defined input and output path .

in below script 'csv' is input folder and contain multiple txt files ,

import pandas as pd import numpy as np import os for file in os.listdir('csv/'): filename = 'csv/{}'.format(file) print(filename) df=pd.read_csv(filename) df.to_csv(path_out) 
2
  • You can look at Pyinstaller - pyinstaller.org Commented Apr 7, 2020 at 4:37
  • for python 3.6 not working pyinstaller Commented Apr 7, 2020 at 6:56

1 Answer 1

0

A simple way you can do this with cx_freeze is as follows:

  1. conda install -c conda-forge cx_freeze, or pip install cx_freeze to your env with numpy and pandas

  2. Make a folder called dist for your new .exe

  3. Save the code below as csv_thing.py, or whatever you want it to be called.

  4. Run the command: cxfreeze csv_thing.py --target-dir C:\somepath\dist

  5. There is a good chance that without using a cx_freeze setup file (spec file in pyinstaller) that not all of the files will get copied over to the dist dir. Numpy and pandas from Anaconda envs are often tricky.

  6. If file failure occurs, you can manually copy the .dll files over into the dist folder; it's easy if you just grab them all. If you're using an Anaconda env, they likely live here: C:\Users\your_user_account\Anaconda3\envs\panel\Library\bin. Otherwise grab all of them from the numpy location: C:\Users\matth\Anaconda3\envs\panel\Lib\site-packages\numpy and copy to the dist dir.


import numpy as np import pandas as pd import os in_dir = input(' enter a folder path where your .csvs are located: ') out_dir = input(' enter a folder path where your .csvs will go: ') csv_list = [os.path.join(in_dir, fn) for fn in next(os.walk(in_dir))[2]if fn.endswith('.csv')] for csv in csv_list: file_name = os.path.basename(csv) print(file_name) df = pd.read_csv(csv) df.to_csv(os.path.join(out_dir, file_name)) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.