Search
Enter at least two characters without personal information.

    LibraryArticles & FAQ Your projectRequest a quote
    LanguageEN
    Practical guides

    Prepare reliable data imports and exports

    A file that opens is not necessarily usable. Reliable exchange preserves field meanings, distinguishes unknown values from zero and matches records without treating a display label as a fragile identifier.

    Go to the method

    Two laptops, external drive and data sheets
    AI-generated illustration

    Describe the data contract

    Write a field dictionary covering meaning, type, unit, required status and missing values. Define stable identifiers and relations. A postal code, product number or administrative code may require a text representation to preserve its meaning.

    Specify encoding, delimiter, dates, time zones and decimal conventions. Python’s CSV documentation explains dialect configuration; a file extension alone does not impose identical conventions on every producer.

    Describe the CSV dialect and test fields before counting lines. In RFC 4180’s comma-separated format, fields containing a comma, double quote or line break are enclosed in double quotes; internal quotes are doubled. The table’s [CRLF] notation represents an actual carriage-return/line-feed pair in the test file. Such a field still belongs to one logical record.

    Test case: a header and two data records, with CRLF inside the second record’s quoted field, occupy four physical lines, not four records. Use a CSV parser and compare fields. Python’s default reader returns strings, so 00120 retains its leading zeros unless a later conversion removes them. Define empty-field meaning and spreadsheet use separately: CSV quoting alone does not neutralise formulas.

    Scroll the table horizontally to read every column. With a keyboard, focus the table area and use the arrow keys.

    Comma-separated CSV: four independent fragments; [CRLF] denotes an actual line break
    Demonstration fragmentField countParsed fields, shown as text
    "Paris, France"1["Paris, France"]
    "A ""B"""1["A \"B\""]
    "A[CRLF]B"1["A[CRLF]B"]
    00120,2["00120", ""]

    Build a batch that challenges the boundaries

    Include an accented name, an optional missing value, an identifier with a leading zero, a multiline description and a missing relation. Add a duplicate and an intentionally invalid format. Keep this dataset synthetic and clearly labelled as test data.

    Decide whether a problem rejects one row, rejects the file or produces an import with an issue report. Avoid reporting success while silently dropping fields. Report accepted, rejected and review-required rows.

    Plan exchange permissions and safety

    Define who can export, import and remove a batch. Do not place confidential exports in a public folder by default. For files opened in spreadsheets, review fields that could be interpreted as formulas using a method appropriate to the receiving software.

    Separate authorised data from internal context that should not travel, such as private comments, unnecessary contact details or technical keys. Use cleaned or synthetic test copies. Document storage, retention and who removes temporary exports.

    Reconcile data after processing

    Compare identifiers, relations, totals and sampled values before and after processing. If round-trip support is required, export and reimport into a test environment, then compare meaning rather than file size alone.

    Keep a backup and record before a destructive import. Distinguish updates, additions and deletion. A missing row in a partial export does not automatically mean that it should be deleted. Agree on these rules before processing the full database.

    Primary documentation : Python : CSV File Reading and Writing.

    Fictional batch: six records carry the text identifiers 00120, 00121, 00120, 00122, 00123 and 00124, in that order. Before import, 00121 exists with a value to change and 00122 exists unchanged. The chosen rule accepts the first occurrence of a key, rejects repeats within the batch and rejects 00123 because a required relationship is missing. The first run therefore yields 2 created + 1 updated + 1 unchanged + 2 rejected = 6 examined records.

    After that run, the target contains four identifiers: 00120, 00121, 00122 and 00124. Replaying exactly the same batch with the same rules and no intervening changes must yield 0 created, 0 updated, 4 unchanged and 2 rejected. This recovery behaviour comes from the chosen import contract, not automatically from CSV. Preserve leading zeros and count logical records read by the parser; a quoted field can contain a line break.

    Scroll the table horizontally to read every column. With a keyboard, focus the table area and use the arrow keys.

    First-run reconciliation of six fictional import records
    OutcomeCountAffected records
    Created200120 and 00124
    Updated100121: value differs from target
    Unchanged100122: value already identical
    Rejected2Occurrence 3: duplicate 00120; occurrence 5: missing relationship for 00123

    Deliver exports with readable filenames in the published languages.

    Synthetic case: an export filename contains accents. Test appropriate filename and filename* parameters, content type and the actually saved file. Sanitize names originating in user input before constructing headers. This header neither protects document access nor replaces authorization checks.

    • The saved filename is readable, content type is accurate and input cannot inject another header.

    Test a data round trip

    Storage drive and USB cable between two laptops
    AI-generated illustration · Compare fields after an export and import round trip.

    Proposed case: export and import change leading-zero codes and dates. Row count stays the same, but values were altered.

    Prepare fictional data with accents, empty cells and sensitive formats. Compare fields after the round trip and keep the report; error-free import does not guarantee fidelity.

    • Define types and encoding
    • Include format-sensitive values
    • Compare fields after import

    Reference documents

    Content updated on

    Documented reference points for this topic

    Documented reference points for this topic
    ReferenceValue or syntaxScope
    RFC 4180 · CSV
    text/csv · "a,b"Fields containing commas, quotes or line breaks are quoted; internal quotes are doubled.
    RFC 8259 · JSON
    application/json · UTF-8Standard JSON permits neither comments nor trailing commas; strings use double quotes.
    RFC 3339 · Date-time
    2026-10-22T09:00:00+02:00The explicit offset relates local time to UTC; this example is not an appointment.

    Dates indicate when references were consulted. These facts are neither a site audit nor an overall compliance statement.

    Acceptance matrix to adapt to your project

    These proposed checks use synthetic cases. Decide the required behaviour with the team, record the result and assign unresolved gaps before release.

    Scroll the table horizontally to read every column. With a keyboard, focus the table area and use the arrow keys.

    Test cases, expected outcomes and useful evidence
    CaseExpected outcomeEvidence to retain
    Accents, separators and multiline textValues keep their meaning after export and reimport.Sample containing accents, a separator inside a field and a line break; values read after round-trip processing.
    Zero, empty, null and absentThe four states follow distinct rules where required by the contract.Data dictionary and values actually received by the destination.
    Repeated identifierThe chosen rule distinguishes duplication, updates and legitimate variants.Accepted and refused row log, with a reason for each decision.
    Failure halfway throughThe team knows which changes were applied and how to resume.Final state, affected rows and a recovery procedure exercised with synthetic data.

    Frequently asked questions

    Why keep some codes as text?

    They identify an entity rather than a quantity. Automatic conversion can lose leading zeros or change presentation. Define the type in the contract and test a boundary example.

    Does an unchanged row count prove a correct import?

    No. Counts may match despite lost fields, broken relations or incorrect replacements. Compare identifiers, values, units and errors using a representative batch.