All guides
PDF & DOCUMENTS

Keep Leading Zeros When Opening PDF Data in Excel

Preserve product codes and other identifiers when importing PDF-to-CSV results into Excel, and check for conversion errors.

PDF365 Editorial••4 min read

A product code such as 00123 can become 123 when Excel interprets it as a number. To preserve identifiers from a PDF-to-CSV export, check the extracted value first, then import that column as text before loading the data into Excel.

Why leading zeros disappear

Codes, postal codes and account identifiers may look numeric, but their leading zeros can be meaningful. Excel can automatically convert numeric-looking text to numbers when opening or importing a CSV. This is a spreadsheet import issue as well as a possible extraction issue: check the CSV against the source PDF to see where a value changed.

Long identifiers need attention too. Excel numbers have 15 digits of precision, so importing a longer identifier as a number can change its later digits. Treat identifiers as text rather than quantities.

    Review the PDF extraction before exporting

    In PDF365 PDF to CSV, select your document and review the proposed columns and extracted rows. Compare identifiers against the PDF and correct any misread characters before exporting. For example, confirm that 00123 in the document is still 00123 in the result; changing the spreadsheet format cannot recover digits that were never extracted.

      Import identifier columns as text in Excel

      Menu names can vary by Excel version. Microsoft documents the following Power Query approach for importing text or CSV files.

      1. Keep the original CSV. In Excel, choose Data, then From Text/CSV, and select the file.
      2. Open the transformation editor from the import preview. Select each identifier column and set its data type to Text before loading.
      3. Check any automatically added type-conversion steps: remove or change a conversion to number that occurs before the text conversion, so the original zeros are not lost first.
      4. Load the data and compare sample codes, long identifiers and row counts with the CSV and the original PDF.

      If the zeros are already missing

      Changing a numeric column to text after import does not recreate missing zeros or digits lost to precision. Reimport the original CSV with the correct type. If the CSV itself is wrong, correct the extracted value against the PDF and export it again.

      Do not add zeros blindly: identifiers can have different lengths. Use a documented fixed width only when the source system specifies one.

        Sources

        1. Keeping leading zeros and large numbersMicrosoft Support
        2. Import or export text (.txt or .csv) filesMicrosoft Support
        TRY IT YOURSELF

        Ready to get started?

        Open the tool and work through the steps at your own pace.

        Open PDF to CSV
        KEEP READINGAll guides