The version of Python I'm using is 2.7.
I have this function in a file called RunAPIGeocoder.py
APIGeocoder.geocode(excel_path=r'{}'.format(input_path))
I need to call this process in the command line and I want to simply pass through an excel file
if I change the function to
APIGeocoder.geocode(excel_path)
and run from CMD
python RunAPIGeocoder.py C:path\Book12019_07_29_16_03_12.875947.xlsx
it will give me this error
NameError: name 'excel_path' is not defined
excel_path is a parameter in the geocode function
I should note I am not trying to use raw_input from the user because this process will be piped into another process and I do not want user input
part of the geocode function in APIGeocoder.py
def geocode(excel_path):
try:
print 'Geocoding in Process...Start Time: {}'.format(time.strftime('%c'))
# Read in data
df_input = pd.read_excel(excel_path, converters={'NodeId':str})
APIGeocoder.geocode(excel_path=input_path). The call toformatdoesn't really accomplish anything.excel_pathis the name of the parameter;input_pathis the name of the argument assigned to the parameter for that function call.APIGeocoder.geocode(excel_path=r'{}'.format(input_path))formatreturnsinput_pathunchanged. The problem with switching fromgeocode(excel_path=...)togeocode(excel_pathin that you are switching from passinginput_pathvia a keyword argument to passing the (nonexistent) local variableexcel_pathas a positional argument.