I have a Python file called data.py
that looks like this:
import json
def txtToJson(textfile):
#rest of the code
def jsontToTxt(jsonfile):
#rest of the code
I am also given a run.sh
file to call each function from the Python file. I have tried doing this:
#!/bin/bash
if [ "$1" = '-s' ]
then
if [ "$2" = '-j' ]
then
##Serialize JSON
python -c "import data; print(data.txtToJson($3))"
fi
elif [ "$1" = '-d' ]
then
if [ "$2" = '-j' ]
then
##Deserialize JSON
python -c "import data; print(data.jsonToText($3))"
fi
fi
However when I try running the script I get a ModuleNotFoundError: No module named 'data'
. How can I get the run.sh
to call the different Python functions properly?