I’m trying to export a table using Python into CSV format specifically for Airtable. When I open the resulting CSV file in Excel, everything seems fine. However, when I upload the file to Airtable, it struggles with strings that include commas, leading to issues.
Here’s an example of what I get:
firstname|lastname|instrument|
john,doe,"violin,piano,guitar"| <-- ERROR
mary|smith|guitar
Compared to what I want to achieve:
firstname | lastname | instrument |
-----------+----------+-----------------------+
john | doe | violin, piano, guitar |
mary | smith | guitar |
Is there a way to adjust my CSV export in Python to resolve this? Is there an alternative method to handle this issue? Below is how I’m currently exporting my CSV:
with open('CRMtest.csv', 'w', newline='') as csvfile:
linewriter = csv.writer(csvfile, delimiter=":", quotechar='"')
for i in range(len(list_names)):
linewriter.writerow([row1[i], row2[i], row3[i]])
Each of my row_X variables contains strings, some of which have commas. Here’s an example:
row1 = 'firstname','john','mary'
row2 = 'lastname','doe','smith'
row3 = 'instrument','violin, piano, guitar','guitar'