A reliable first import
Importing data is the controlled translation of a file into an analysis-ready table. Before clicking Import or calling a function, inspect a few raw lines.
Identify the delimiter, whether the first row contains field names, the text encoding, the decimal convention, and how missing values are represented. A file extension is only a hint: a file named .csv may use semicolons, tabs, or a legacy encoding.
A documented import maps the file's conventions into an analysis-ready table without silently changing records.
Make every assumption explicit in an import specification. For a comma-delimited file with a header, choose comma as the delimiter and preserve the first row as names.
If a cell can itself contain a comma, it must be quoted; a capable parser treats the quoted comma as part of one field.
Specify missing-value tokens such as a blank cell, NA, or a stated sentinel before analysis. Identifier columns often need to be imported as text so leading zeros remain part of the identifier.
Worked example
Imagine a survey file whose first line is student_id,program and whose later rows contain values like 0042,Science. A correct import uses the header and keeps student_id as text. If it is read as a number, the visible value may become 42 and no longer match an external record.
When the columns are right but the characters are wrong
A delimiter problem changes the table's shape. For a UTF-8 file read as ISO-8859-1, an encoding mismatch can corrupt characters while leaving the parsed shape intact when the file uses ASCII-compatible delimiters and line endings, such as a comma and LF.
Those ASCII bytes have the same values in UTF-8 and ISO-8859-1, so a compatible parser can still recognise field and record boundaries.
That behavior is specific to this combination: other encoding mismatches may fail during decoding or disrupt parsing. For example, reading UTF-16LE as ISO-8859-1 places NUL characters between the ASCII letters of a header, which can interfere with header recognition.
An encoding is simply the rule that maps a file's bytes onto characters, and an encoding mismatch matters when the same byte values represent different characters under the reader’s encoding.
Two families matter here: single-byte encodings such as Latin-1 (ISO-8859-1), which gives every one of the 256 possible bytes its own character, and multi-byte encodings such as UTF-8, today's usual choice, which spend two or more bytes on any character outside the plain ASCII range.
Worked example: a Latin-1 file read as UTF-8
Suppose a legacy system writes Zürich in Latin-1, storing the ü as the single byte FC, and the import declares UTF-8. FC is not a valid byte in a UTF-8 sequence.
With strict decoding, the import raises a decoding error; with replacement handling, it yields Z�rich; and with ignore mode, it drops FC and yields Zrich.
Now reverse the two roles, in the specific case of a UTF-8 file read as ISO-8859-1. ISO-8859-1 maps every byte from 00 to FF to a character, so this decoding itself reports no invalid-byte error.
If delimiters and line endings use ASCII-compatible bytes such as comma and LF (or CRLF), those bytes keep the same values in both encodings, allowing a compatible parser to recognise field and record boundaries.
Each byte of a non-ASCII UTF-8 character is then decoded separately, so that character arrives as a short run of two or more unexpected characters, the same run each time it appears.
That silent one-to-many expansion is the signature to recognise for this UTF-8/ISO-8859-1 mismatch. It does not establish that other encoding mismatches preserve the table shape.
The repair is the same in both directions and belongs at read time: find out which encoding the producing system actually used, declare it, and import again.
The bytes on disk are not damaged and need no correction, only a correct instruction for interpreting them. Editing mangled values in a spreadsheet afterwards fixes today's table and leaves tomorrow's import just as broken.
Rows are records, not lines
After import, compare the row count, column names, and a few raw records with the original file. This is a fast check for shifted columns, lost headers, or wrongly split text.
One caution keeps the check honest: a quoted field may itself contain a line break, in which case a single record occupies two or more physical lines and the file's line count legitimately exceeds its record count.
A line-counting utility counts lines; a parser that honours quoting counts records. A gap between the two numbers is not automatically an error, but it should always have an explanation.
Save the import code or settings beside the project so another analyst can rerun the same translation.
Common mistake: repairing a broken import manually in a spreadsheet and then continuing without recording what changed. Fix the parser settings instead, so the process is reproducible.
The raw file in the figure contains the field "Arts, BA". Why should a CSV parser preserve this as one field?
A documented import maps the file's conventions into an analysis-ready table without silently changing records.
A data file uses semicolons between fields and is imported with a comma delimiter. None of the field values contains a comma. What is the most likely immediate symptom?