Select to view content in your preferred language

Quicker Export CSV Option

207
2
07-03-2024 10:36 AM
Status: Open
Labels (1)
JamesPoeschel
Occasional Contributor

I would like a quicker way to export CSVs. Having to go to export table, then navigate out of the default gdb and into the default folder, then specifying the file type, is tedious.
I wish there were an "Export CSV" button under the Export Table button. Ideally the output would default to the default folder connection with the file type defaulting to .csv.
I've heard this complaint from a few people in my office so I figured I would post it here.

JamesPoeschel_0-1720027826082.png

After exporting csvs I also get an unnecessary XML document which I would hope would be excluded if this were to be implemented as it creates clutter.

JamesPoeschel_0-1720028504817.png

 

 

2 Comments
BruceHarold

You could add a script tool to the Quick Access toolbar that has a table input and writes CSV to the project home folder.

JamesPoeschel

@BruceHarold Thank you! That's a good work around.

In case anyone is interested, here is the code below. The only parameter is the input table that takes the data type Table View.

 

import arcpy
import os

# Get input table parameter
inputTable = arcpy.GetParameterAsText(0)

# Get the project home folder
homeFolder = arcpy.mp.ArcGISProject("CURRENT").homeFolder

# Create the output CSV file name
outputCSV = os.path.join(homeFolder, f"{os.path.basename(inputTable)}.csv")

# Export the table to CSV
arcpy.conversion.TableToTable(inputTable, homeFolder, os.path.basename(outputCSV))

# Construct the .csv.xml file path
outputCSVXML = f"{outputCSV}.xml"

# Delete the .csv.xml file if it exists
if os.path.exists(outputCSVXML):
os.remove(outputCSVXML)