How to swap out characters in a CSV file using Python within Zapier?

I’m just starting out with Python and Zapier, so please bear with me if I’m asking something basic or seemingly impossible...

I need to upload several CSV files to Zapier for an automated process, but they include bullet points that are not encoded in UTF-8, which is the only encoding Zapier accepts.

This leads to a frequent error message - "utf-8' codec can't decode byte 0x95 in position 829: invalid start byte"

After consulting Zapier support, they recommended utilizing Python to locate and replace these bullet points with either an asterisk or a dash, and then upload the modified CSV back into my Zapier workflow.

Here’s what I have drafted so far for a Python code action in Zapier attempting to read the CSV file, but it hasn’t worked:

import csv
with open(input_data['file_path'], 'r') as data:
    csv_reader = csv.reader(data)
    for line in csv_reader:
        print(line)

Is this achievable?

Thank you!

Hey, you can try reading and writing the file with errors='replace' to bypass those non-utf8 points. Then, replace the special chars with .replace(). Make sure to open with correct encoding, like 'latin1' or 'iso-8859-1' if UTF-8 gives problems. Hope this helps!