ModifyfilesModifyfiles

Change the file. Keep what matters.

Home
  • File Conversion Techniques
  • Document Formats
  • Keep Identifiers and Dates Intact When You Import a CSV

Keep Identifiers and Dates Intact When You Import a CSV

Import CSV files without losing leading zeros, long identifiers, or date meaning. Check column types, source conventions, and the next file handoff.

Keep Identifiers and Dates Intact When You Import a CSV
2.3k

A CSV can look neatly arranged in a spreadsheet while some of its values have already changed. A product code loses its first zero. A long identifier ends in different digits. A date switches from April 5 to May 4 without producing an obvious error.

The useful check is whether each field still means what the source intended. Before editing a CSV, decide which columns contain quantities, which contain identifiers, and which need an explicit date convention. Then import and verify them deliberately.

Classify the columns before opening the working copy

Keep an untouched copy of the original export. If you need to inspect its contents, use a plain-text viewer that does not interpret the fields as spreadsheet values. Work with files from a source you trust, and avoid uploading private records to an unfamiliar converter.

Consider this fictional stock-file sample:

  • Product code: 004812
  • Quantity available: 12
  • External reference: 12345678901234567
  • Recorded date: 04/05/2026

The product code and external reference identify things. Adding them together would serve no purpose, so preserve them as text. Quantity is a number because arithmetic is meaningful. The date needs more information: does the source use month/day/year or day/month/year?

Make a small column note before importing: product code as text, quantity as a whole number, external reference as text, and recorded date temporarily as text. This note becomes your test plan, especially when different people handle the same export.

Use the import preview to control interpretation

Microsoft's Excel documentation distinguishes directly opening a CSV from importing it with controls over column types. Direct opening can use the current default settings to interpret values. Where available, start with Data, then From Text/CSV, and open the transformation editor rather than accepting the first preview unchanged. Labels vary by Excel version.

First check that the expected headings occupy separate columns and that the row contents line up beneath them. If an entire record appears in one column, examine the delimiter setting. If a description splits unexpectedly, check whether quoted separators are being handled correctly. Do not repair hundreds of rows by moving cells until you understand the parsing problem.

Before loading, inspect any automatic type-conversion step already applied by the importer. In Power Query this can appear as Changed Type. Remove or revise any conversion that treats identifiers as numbers or unresolved date fields as dates, then assign Text to those columns. If Excel offers Replace Current when changing the type, use it rather than adding a Text conversion after the unwanted conversion. Confirm that the resulting text matches the original file.

Microsoft documents automatic type detection for unstructured sources such as CSV files. A preview that looks right at the top does not establish that every later value follows the same pattern. Check distinctive examples farther down the file as well.

Resolve dates using the source's convention

Keep an ambiguous date as text until the exporting system's documentation or the file's owner confirms its meaning. The fictional 04/05/2026 cannot settle its own interpretation. A nearby 18/05/2026 is a useful clue, but a mixed-source file might contain more than one convention.

Once the convention is known, use an import conversion that explicitly matches it, including the appropriate locale where the tool offers that option. Check a date that would be ambiguous and one whose day is greater than twelve. If different parts of the file follow different conventions, separate those groups before conversion.

For a handoff, state the date format in the column note. If the receiving system requires a particular representation, follow its import specification rather than assuming the date's appearance in your workbook will control the next import.

Check the stored value, not just its appearance

Compare several imported values character by character with the untouched source. Include a code beginning with zero, a long reference, a blank field, and a value containing punctuation. Confirm that blanks have not been casually replaced with zero or with a word that the destination will treat as real data.

Microsoft warns that Excel's numeric precision can affect identifiers longer than fifteen digits. Making the column wider or changing its display format cannot recover digits already discarded. Reimport the original value as text. Likewise, do not guess how many zeros belong in a code after they have disappeared.

A custom number format can make a short number display with leading zeros inside a workbook, but that is a different choice from preserving an identifier as text. For files moving between systems, verify the actual exported characters rather than relying on the way the cells look.

Test the next handoff

Save the working workbook separately if you need to retain its import steps or formatting. When a CSV export is required, create a new output file and inspect representative rows in plain text. Then test a small, non-sensitive sample in the receiving system if possible.

Compare the sample's codes, references, dates, row count, and column alignment after that import. Record any required import settings alongside the file. A clean result at both ends is stronger evidence than a spreadsheet that merely looks tidy in the middle.

Onward reading