Mod:Hunt Research Group/chelpg extract
Before running the code please ensure you have XlsxWriter python module and python version later than 3.5.
Python code to extract charge values from CHELPG calculation log file: File:Chelpg.txt
Here is an example log file to test the code: File:Test chelpg.log
Here is the correct excel file the code should generate: File:Test chelpg.xlsx
Python code to extract charge values from NBO calculation log file: File:Nbo charge script.txt
Here is an example log file to test the code: File:Test nbo.log
Here is the correct excel file the code should generate: File:Test nbo.xlsx
Instructions to run the python code from the same directory:
1. Download the code, change the extension to .py and place the code at the same directory as the .log file from CHELPG or NBO calculation you want to extract the charge values
2. Type either
python chelpg.py
or
python nbo_charge_script.py
to run the code
3. The code will ask
Enter filename:
type the name of the .log file exactly as it is, e.g.
test_chelpg.log
4. If the code has run successfully, it should generate an excel file with the title same as the log file and return
Generated your_file_name.xlsx file
Instructions to run the python code with alias:
If you need to do CHELPG or NBO analysis on many log files, it may be more convenient to create an alias rather than copying the code to the directory each time you need to run the code. Here are the instructions:
1. Download the code, change the extension to .py and place the code at the desired directory. I would recommend creating a folder dedicated to python scripts at your home directory.
2. Go to your home directory and type:
vim .bash_profile
3. Enter following texts to .bash_profile file where the alias are:
alias nbo_charge="python ~/path/to/directory/where/you/placed/python/scripts/nbo_charge_script.py"
alias chelpg_charge="python ~/path/to/directory/where/you/placed/python/scripts/chelp.py"
4. Now go to the directory where you have the .log files you want to extract charge values from NBO or CHELPG calculation. You can now run the code by simply typing the commands below to the terminal:
nbo_charge
or
chelpg_charge