Convert between CSV and DBF

What a CSV to DBF (or DBF to CSV) conversion changes, where data can be truncated or garbled, and how to check that the converted file is still usable.

Converting between CSV and DBF moves tabular data between two different kinds of files. CSV is plain text that almost any tool can read. DBF is the structured binary table format from the dBase family, still used by older database applications and by GIS shapefiles for their attribute tables. A converter can do this in either direction. This review explains what the conversion changes, where meaning can be lost, and how to decide whether the result will hold up for your purpose.

Short verdict: when the conversion is worth doing

Convert CSV to DBF when a specific destination requires DBF. Typical examples are a legacy dBase, FoxPro or Clipper-era application, or a shapefile attribute table that GIS software has to read. Convert DBF to CSV when you need to get data out of those systems and into spreadsheets, scripts or modern databases. The main benefit of DBF is a declared schema: each field has a name, a type and a width that the receiving software can rely on. The decisive tradeoff is that this schema imposes hard limits. Field names can be shortened, long values can be truncated, and characters outside the chosen code page can be garbled, sometimes without any warning. Keep the data as plain CSV, preferably UTF-8, when no system demands DBF, when you are sharing with people rather than software, when values contain long free text or many scripts and symbols, or when you need to track changes over time.

What the conversion actually changes

This is not a visual or styling transformation. Nothing is mirrored, reversed or restyled, and no fonts are involved. The conversion rewrites the stored bytes and the structure of the data. A CSV file is a sequence of text lines in which delimiters separate the values and quotation marks protect values that contain delimiters or line breaks. A DBF file starts with a binary header that describes every field. After the header comes a set of fixed-length records. Each record begins with a deletion flag, and character values are padded with spaces to fill the field width. Converting between the two means either inferring a schema from text (CSV to DBF) or flattening a typed schema back into text (DBF to CSV).

Aspect | CSV | DBF
Storage | Plain text, one record per line | Binary header plus fixed-length records
Column names | Optional header row, any length | Stored in the header, limited to 10 characters in the classic format
Data types | None declared; everything is text | Declared per field, e.g. character, numeric, date, logical, memo
Value length | Unlimited in principle | Fixed width per field; character fields commonly capped at 254 bytes in classic dBase
Text encoding | Not declared in the file | Optional code page marker in the header, not always set or honored
Empty values | Empty string between delimiters | Usually blank-padded; classic dialects have no true null
Long text | Inline in the field | Memo fields kept in a separate companion file
Deleted rows | Not applicable | Flagged but still present until the table is packed
Readable without special software | Yes | No

CSV to DBF: where values can change

  • Field names longer than 10 characters must be shortened, and shortened names can collide (two columns both becoming the same truncated name).
  • Values longer than the field width are cut off, often silently.
  • Character widths are measured in bytes, so in a multibyte encoding an accented or non-Latin character uses more of the width than a plain letter does.
  • Number-like text such as postal codes, account numbers or IDs loses its leading zeros if the converter types the column as numeric.
  • Dates in CSV can be written in many styles, but DBF date fields store a fixed year-month-day form. Ambiguous strings such as 03/05 can be misread.
  • Decimal separators and thousands separators depend on locale, and a misread separator changes the numeric value.
  • Characters that do not exist in the target code page are replaced or garbled. Text with combining marks (a base letter plus a separate accent code point) may fail even when the precomposed form of the same letter would map cleanly.
  • Emoji and many symbols have no representation in the single-byte code pages that DBF readers typically expect.
  • Embedded line breaks and quoted commas only survive if the converter parses CSV quoting correctly.

DBF to CSV: where information can be lost

  • Field types and widths are dropped. The CSV no longer tells the next tool which column is a date or a number.
  • Character values may keep their trailing padding spaces unless the converter trims them, and trimming can also remove spaces that were meant to be there.
  • Records flagged as deleted may be included or excluded depending on the converter. Check which one your tool does.
  • Memo text lives in a separate companion file. If that file is missing or not read, the memo columns come out empty or as raw pointers.
  • If the code page marker is wrong or ignored, accented and non-Latin text is decoded incorrectly. The CSV then contains permanently wrong characters unless you reconvert from the original DBF.
  • Later dialects add field types and null support that some converters do not recognize, so those columns may be skipped or misread.

An illustrative example

The sample below is constructed to show the risk points. It is not output from any tested converter.

id,customer_reference,postal_code,name,signup_date,notes
1,ACME-0042,02134,Zoë Martín,2024-03-05,"Prefers email, not phone"
2,ACME-0107,00501,Ana Ruiz,05/03/2024,"Two-line note:
call after 5pm"

A strict conversion to classic DBF has to rename customer_reference (18 characters) and postal_code (11 characters) to 10 characters or fewer. If postal_code is typed as numeric, 02134 becomes 2134 and 00501 becomes 501. The two signup_date values use different conventions, and 05/03/2024 could be read as May 3 or March 5. Whether Zoë and Martín survive depends on the chosen code page and on whether the accents are stored as single precomposed characters or as base letters plus combining marks. The quoted comma and the line break in the notes column are kept only if the converter follows CSV quoting rules. If any of these values is wider than the field width the converter assigns, it is truncated.

Will the result stay readable and usable after sharing?

Copying and pasting: CSV can be opened in any text editor and pasted into messages, tickets or documents with its content intact. DBF is binary. Opening it in a text editor shows header bytes and space-padded records, and pasting that into a message does not transfer usable data. Share a DBF as a file attachment, and expect the recipient to need software that reads the specific DBF dialect.

Accessibility: a CSV opened as raw text is read aloud by assistive technology as one long string of values and delimiters, which makes it hard to tell which value belongs to which column. Opened in a spreadsheet or table viewer, the same file can expose its rows and columns. A DBF file is accessible only to the extent that the application displaying it is accessible. No scoped tests with named screen readers or viewers were available for this review, so no claims are made about specific products.

Search, editing and change tracking: CSV works with ordinary text search, comparison and version-control tools. DBF needs a tool that understands the format. Editing a DBF by hand risks corrupting the record count and the fixed widths stored in the header, so make changes in an application built for DBF, or edit the CSV and convert again.

When you need a plain-text equivalent: if the DBF exists only to satisfy one system, keep a UTF-8 CSV as the master copy and regenerate the DBF from it whenever the data changes. That way you keep a readable, searchable and accessible version, and the DBF's limits never become the only record of the data.

Checks before trusting a converted file

  • Compare row counts between the source and the output, and account for deleted DBF records.
  • Record how every field name was mapped, especially any that were shortened.
  • Review the assigned field types, widths and decimal places before converting, not after.
  • Spot-check the longest value in each text column for truncation.
  • Check identifiers and codes for lost leading zeros.
  • Check a sample of dates, particularly ambiguous day-month values.
  • Inspect rows with accented, non-Latin or symbol characters in the destination application itself.
  • Confirm that memo text is present when converting from DBF.
  • Where possible, run a round trip (CSV to DBF to CSV) and compare it with the original to expose silent changes.

What to look for in a converter

Useful capabilities include explicit control over field names, types, widths and decimals; selectable input encoding and output code page; correct handling of quoted CSV fields; a clear option for including or excluding deleted records; support for memo companion files; and warnings when values are truncated, rather than silent truncation. For sensitive data, prefer converters that run locally. A tool's appearance or marketing language says nothing reliable about whether an online service stores uploaded files. Rely only on the provider's documented retention policy, and if none exists, assume the risk is unknown.

Limits of this review

No specific converter was tested, and no measurements, prices or product claims are offered here. Behavior differs across DBF dialects (dBase III and IV, FoxPro, Visual FoxPro) and across the applications that read them. Confirm field limits, supported types and encoding handling against the documentation for the exact software that will receive the file, and then test with a representative sample of your own data.