← Back to the blog

Import CSV and Excel into a database: 5 checks

CSV and Excel files are how every team swaps data: a supplier price list, a partner export, a list someone cleaned up by hand. Loading them into a database looks like a five-minute job, and that is why it goes wrong so often. Bad imports create data that is hard to find and harder to repair. Use this checklist before you press import.

1. Encoding

Thai and other non-Latin text must be saved as UTF-8. If a CSV was exported from an older tool in a legacy encoding, the characters turn into question marks or gibberish after import and you cannot recover them from the database; you have to re-import. Open the file in a text editor first and look at a few Thai rows. Excel's "CSV UTF-8" save option is the safe choice.

2. Dates

Agree on one date format before you start. 03/04/2026 is the third of April in some countries and the fourth of March in others. For Thai sources, check whether years are Buddhist era (2569) or Gregorian (2026); a column with a mix of both is common after manual editing. ISO format (2026-04-03) avoids almost all confusion.

3. Data types and leading zeros

Spreadsheets love to turn things into numbers. A postal code 01000 becomes 1000, a phone number loses its leading zero, a long ID turns into scientific notation (1.23E+15). Mark these columns as text before saving, and map them to text columns in the database.

4. Duplicate and missing keys

Before importing into a table that has a primary key or a unique index, check the file for duplicate keys and for rows with an empty key. Also decide what should happen when a key already exists in the table: skip it, replace it, or stop. Importing with no plan for collisions is how existing records get overwritten by an older file.

-- after importing into a staging table, find duplicate keys
SELECT sku, COUNT(*) AS n
FROM   import_products
GROUP  BY sku
HAVING COUNT(*) > 1;

5. Import into a new table first

Load the file into a separate staging table, look at it, and only then insert or merge into the live table. This gives you a place to run the checks above and to roll back by simply dropping the staging table. It takes an extra minute and prevents most import incidents.

Verify afterwards

  • The row count in the table equals the row count in the file (minus the header).
  • Totals of a numeric column match between the file and the table.
  • Five random rows look identical to the original, including Thai text and dates.
  • The number of empty values per column is what you expect.

In Ruamhub

Ruamhub imports CSV and Excel files as tables and shows a preview before you confirm, so you can catch encoding and column problems early. The import is recorded in the audit log together with the user who ran it.

Bring all your databases into one place

Start free, or book a demo and we will walk through it with your own team’s data.