Sheets5 min read

How to keep leading zeros in ChatGPT CSV uploads

Read ZIP codes and identifiers as strings from the moment you import them. Check the raw CSV in a text editor first. If the file already contains 2134 where you expected 02134, fix the source export before testing ChatGPT’s parsing.

Use the fictional sample provided here or a file you are authorized to share. Review the AI tool’s data policy before uploading your own files.

On this page

Find the stage that changed the value

Open the CSV in a plain-text editor and inspect a row with a known leading zero. Then compare it to the output from ChatGPT. Finally, check any downloaded or exported CSV in a text editor before opening it in Excel. This isolates a source export problem, import-time type inference, or a change introduced when opening the output.

Use explicit text typing

The sample includes three fictional records with a zip_code column. Ask ChatGPT to import it as text from the start and provide JSON strings so you can see the quoted values. With pandas, the import argument is dtype={'zip_code': str}. For your own file, apply that pattern to all identifier columns. Keep genuine quantities numeric when you need to calculate with them.

Try it with a sample file

Download CSV

Read the attached CSV with zip_code typed as a string during import. Return each site and its ZIP code as a JSON string. Keep every original digit and flag values you cannot verify.

Show expected result

North: "02134". East: "00501". West: "90210". Each ZIP code is a five-character string.

Keep the zeros when returning to Excel

Use Data → From Text/CSV and set the ZIP column to Text in the import workflow, before a numeric conversion drops the zeros. If a transformation already changed the type, correct or remove that transformation. Recover lost digits from the original export. Padding a short value is only safe when you know the field’s required width and every value follows the same format.

Sources