To overwrite outputs, set arcpy.env.overwriteOutput = True.
(Read and Write)
Controls whether tools will automatically overwrite any existing output when run. When set to True, tools will execute and overwrite the output dataset. When set to False, existing outputs will not be overwritten, and the tool will return an error.
In my testing the output CSV always had an OID field added to it, so I used the pandas library to drop the OID field.
import pandas as pd
arcpy.env.overwriteOutput = True
# Input Excel file
excel_file = r"C:\Users\Username\Desktop\test_book.xlsx"
# Intermediate converted table
interm_table = r"C:\Users\Username\Documents\ArcGIS\Default.gdb\test_book"
# Convert Excel file to table
arcpy.ExcelToTable_conversion(excel_file, interm_table, "Sheet1")
# Directory and name for the output CSV
output_dir = r"C:\Users\Username\Desktop"
csv_name = "test_book.csv"
# Convert intermediate table to CSV
arcpy.TableToTable_conversion(interm_table, output_dir, csv_name)
# Set full path of the CSV
csv_fullpath = output_dir + "\\" + csv_name
# Read CSV into pandas DataFrame
df = pd.read_csv(csv_fullpath)
# Drop OID column
df.drop('OID', axis=1, inplace=True)
# Write DataFrame to the same CSV as the input
The OP asked about Model Builder. I think pandas is a little more than they were interested in... did you try simply modifying the field map on the Table to Table tool to drop the OID? Seems like that would be less trouble (especially if using Model Builder).
Yeah, I tried using FieldMappings and also tried using table view FieldInfo. With field mapping, the ObjectID field didn't seem to be accessible using the fields property of the FieldMappings object. With FieldInfo, even if I hid the ObjectID field it still showed up in the output CSV. Hiding fields worked with all the other fields, just not ObjectID.
Just wanted to say thank you for posting this solution as I was able to use some of the code to help with a similar process of dropping the "OID" field from a CSV file that was exported from the "Table to Table" tool.