I am fairly new to python toolbox and I am trying to input a text file path into my script to further use with pandas (pd.read_csv()). However, everytime I extract my parameter, the file path returned uses '\' as separator. If I've learn one thing in Python, is that you never want to use backslashes. How do I get rid of those or how can I get my parameter to know that the string is a file path and read it appropriately.
def getParameterInfo(self):
param0 = arcpy.Parameter(
displayName="File path to enter",
name="path",
datatype="DETextfile",
parameterType="Required",
direction="Input")
params = [param0]
return params
def execute(self, parameters, messages):
path = parameters[0].valueAsText
arcpy.AddMessage(path)
Output :
C:\Users\xyz\FileName.txt
The pd.read_csv function does not accept this file path format.
Thanks!