DEV Community

Mahizul Islam
Mahizul Islam

Posted on

5 Common CSV Problems and How to Fix Them

5 Common CSV Problems and How to Fix Them

CSV files are everywhere — database exports, spreadsheet
data, API responses, analytics reports. But anyone who
works with CSV regularly knows the frustration: files
that look fine but break on import, columns that won't
split, characters that turn into gibberish.

Here are the 5 most common CSV problems and exactly
how to fix each one.


1. Broken or Garbled Characters (’, é, £)

What it looks like:
Your CSV opens and instead of apostrophes you see ’,
instead of é you see é, instead of £ you see £.

Why it happens:
Your file was saved in Windows-1252 encoding (Excel's
default on Windows) but opened as UTF-8. The two
encodings interpret the same bytes differently.

How to fix it:

In Python:

import pandas as pd
df = pd.read_csv('file.csv', encoding='windows-1252')
df.to_csv('fixed.csv', encoding='utf-8', index=False)
Enter fullscreen mode Exit fullscreen mode

In Node.js:

const iconv = require('iconv-lite');
const fs = require('fs');
const buf = fs.readFileSync('file.csv');
const text = iconv.decode(buf, 'win1252');
fs.writeFileSync('fixed.csv', text, 'utf8');
Enter fullscreen mode Exit fullscreen mode

No-code option: Use a free CSV to UTF-8 Converter
that auto-detects the encoding and converts instantly
in your browser.


2. All Data Appears in One Column

What it looks like:
You open a CSV in Excel and instead of separate columns,
everything is crammed into column A.

Why it happens:
Your file uses a semicolon, tab, or pipe as the delimiter
instead of a comma. Excel in European countries defaults
to semicolons because commas are used as decimal separators.

How to fix it:

In Excel: Don't double-click the file. Instead go to
Data → From Text/CSV → select your file → choose the
correct delimiter in the preview.

In Python:

import pandas as pd
# Try semicolon delimiter
df = pd.read_csv('file.csv', sep=';')
# Or tab
df = pd.read_csv('file.csv', sep='\t')
Enter fullscreen mode Exit fullscreen mode

No-code option: Use a free CSV Delimiter Changer
to convert between comma, semicolon, tab, and pipe
delimiters instantly.


3. Inconsistent Column Count

What it looks like:
Row 1 has 5 columns, row 47 has 4, row 203 has 6.
Your import fails with an error like "too many values
to unpack."

Why it happens:
Values containing commas weren't properly quoted,
or rows were manually edited and a field was accidentally
deleted or duplicated.

How to fix it:

In Python:

import csv

with open('file.csv') as f:
    reader = csv.reader(f)
    headers = next(reader)
    expected = len(headers)
    for i, row in enumerate(reader, 2):
        if len(row) != expected:
            print(f"Row {i}: {len(row)} columns (expected {expected})")
Enter fullscreen mode Exit fullscreen mode

No-code option: Use a free CSV Validator
that checks column consistency, empty headers,
duplicate rows, and broken quotes with a detailed
line-by-line report.


4. Duplicate Rows

What it looks like:
You import your CSV into a database and get primary
key conflicts, or your analytics show inflated numbers
because the same record appears multiple times.

Why it happens:
Data was exported twice, two files were merged without
deduplication, or a sync process ran multiple times.

How to fix it:

In Python:

import pandas as pd
df = pd.read_csv('file.csv')
df_clean = df.drop_duplicates()
# Or deduplicate on a specific column
df_clean = df.drop_duplicates(subset=['email'])
df_clean.to_csv('clean.csv', index=False)
Enter fullscreen mode Exit fullscreen mode

No-code option: Use a free CSV Duplicate Remover
that supports full-row and column-specific deduplication
with case-insensitive matching.


5. Empty Rows and Trailing Whitespace

What it looks like:
Your row count is wrong, or string comparisons fail
because "Alice" and "Alice " are treated as different
values.

Why it happens:
Exported data often includes empty rows at the end,
and spreadsheet editors sometimes add invisible
trailing spaces.

How to fix it:

In Python:

import pandas as pd
df = pd.read_csv('file.csv')

# Remove empty rows
df = df.dropna(how='all')

# Trim whitespace from all string columns
df = df.apply(lambda x: x.str.strip() if x.dtype == 'object' else x)

df.to_csv('clean.csv', index=False)
Enter fullscreen mode Exit fullscreen mode

No-code option: Use a free CSV Cleaner
that removes empty rows, trims spaces, removes
duplicate rows, and strips non-printable characters
in one click.


Summary

Problem Quick Fix
Garbled characters Convert to UTF-8
All data in one column Change delimiter
Inconsistent columns Validate before import
Duplicate rows Deduplicate on key column
Empty rows / whitespace Clean before processing

All the tools linked in this article are free and
browser-based — your data never leaves your device.
Check out the full CSV Toolkit
for 16 tools covering everything CSV.

Top comments (0)