I've created a script tool in ArcGIS Pro that asks the user to select a csv file, and then reads that csv file into a pandas DataFrame and performs some calculations. I'd like to be able to export a new csv file after the calculations are complete in the same folder as the input csv file.
For example, the user selects the input csv file from (C:\Users\Luis\GIS\input.csv). I'd like to export a new csv at the end of the script to (C:\Users\Luis\GIS\output.csv)
The parameter that reads in the user input is set up as follows:
input_csv = arcpy.GetParameterAsText(0)
The data type for this parameter is File is the Tool Properties in ArcGIS Pro.
Get the output csv filename as a parameter (output direction) and use df.to_csv to write it out.
input_csv = arcpy.GetParameterAsText(0)
output_csv = arcpy.GetParameterAsText(1)
df = pandas.read_csv(input_csv)
#do some calcs
df.to_csv(output_csv, index=False)