I am writing a standalone Python script which involves exporting a geodatabase table to a CSV at a location specified by the user. The script will be called via the command line, and the location is one of the arguments.
Ideally, the user would be able to specify the location in a way that's familiar to them. They are not Python coders, and the script is non-interactive so I can't present a dialog box where they select the location. Most likely, they will copy-paste a location from Windows Explorer.
There are three areas where I'm seeking assistance:
- How to pass the location argument if it include spaces. The below approach does not work in this scenario. Shall I enclose the arguments in some delimiter? If so, how do I parse the arguments then? Note that there are other arguments as well.
- How to split apart outFile into the path and the filename. These will be used by arcpy.TableToTable_conversion(), which requires these as separate parameters.
- How to reformat the path such that it includes proper escaping such as the double-backlashes.
outFile = sys.argv[2]
outPath =
outFileName =
arcpy.TableToTable_conversion(targetTable,outPath,outFileName)