๐ง Tutorial ยท 6 min read
How to Open a CSV File in Linux (Terminal & GUI)
To open a CSV in Linux, page through it with less data.csv, peek at the top with head -n 5 data.csv, or double-click it into LibreOffice Calc. A CSV is just plain text, so anything can open it โ the reason people get stuck is that the tools which split on the comma (awk, cut, a naive column call) misread any field that contains a comma inside quotes. This guide covers the terminal and desktop paths, and the one file that breaks each.
The quick answer
less data.csv # page through the raw text
head -n 5 data.csv # first 5 lines
column -s, -t < data.csv | less -S # align fields into columns
libreoffice --calc data.csv # open in the GUI
Use the first two to look, the third to line up fields on a well-formed file, and the fourth when you want a spreadsheet. For anything with quoted commas or embedded line breaks, parse it โ see the parser section below.
Look at the file without a parser: less, cat, head, tail
When you only need to see whether the file is comma-separated, tab-separated or full of semicolons, read the raw text:
less data.csvโ scroll a large file without loading it all;qto quit,/termto search.head -n 20 data.csvโ the header plus the first rows, which is usually enough to spot the delimiter.tail -n 20 data.csvโ check the end for a footer row or ragged final line.cat -A data.csv | headโ reveal hidden characters:^Ifor a tab,^M$for Windows CRLF line endings.
Recent less builds read a CSV as a whole record rather than by physical line, but the classic advice still holds: if rows look wrapped or ragged, you are seeing line breaks that sit inside quoted fields.
Line up the fields โ and know where it breaks
The column command (GNU coreutils) turns a delimited file into aligned columns, which makes a small CSV far easier to read than raw text:
column -s, -t < data.csv | less -S
But column splits on the delimiter literally, so it is not a CSV parser. The same trap catches awk -F,, cut -d, and str.split(","). On a file whose second field is "Doe, Jane" and whose third spans two lines, this is what happens:
$ awk -F, '{print NF" fields: "$1" | "$2}' t.csv
3 fields: name | city
4 fields: "Doe | Jane"
1 fields: and commas" |
3 fields: Bob | Tokyo
Three records became four fragments, because RFC 4180 lets a field contain a comma when it is wrapped in double quotes. A quote-aware parser reads the same file correctly:
$ python3 -c "import csv;[print(r) for r in csv.reader(open('t.csv',newline='',encoding='utf-8'))]"
['name', 'city', 'note']
['Doe, Jane', 'Paris', 'likes "quotes"\nand commas']
['Bob', 'Tokyo', 'plain']
That is the rule to carry: any time you split a CSV on a single character in the shell, you are trusting that no field holds that character. When your data comes from a CRM, a bank export or a form, do not trust it.
Parse it properly: csvkit and Python
Two ways to stay in the terminal and still parse correctly.
csvkit (a Python tool you install with pipx install csvkit or pip install csvkit) adds CSV-aware commands. csvlook prints an aligned table, csvstat summarises columns, and csvgrep filters rows:
csvlook data.csv
csvstat --count data.csv
csvgrep -c city -m Paris data.csv
The Python standard library needs no install at all โ Python ships with every mainstream Linux distribution. One line gives you a correct parse, and you can pipe it through head for a quick look:
python3 -c "import csv;[print(r) for r in csv.reader(open('data.csv',newline='',encoding='utf-8'))]" | head
If you will script the file rather than just look at it, the same module is covered in more detail in how to open a CSV in Python. To query a CSV with SQL instead of filtering by hand, see query a CSV with SQL.
Count rows correctly: wc -l is a trap
wc -l data.csv counts newline characters, not records. Our three-record test file reports four, because one record contains a line break inside a quoted field:
$ wc -l t.csv
4 t.csv
There are two ways this bites: a quoted line break inflates the count, and a file whose last line has no trailing newline makes it one short. For an exact count, parse it โ csvstat --count data.csv, or the Python reader above. The row-count problem is the same one described in count rows in a CSV file.
Fix encoding before it garbles your view
If less shows symbols where accents should be, the file is not UTF-8. Identify it, then re-encode:
file -i data.csv
iconv -f LATIN1 -t UTF-8 data.csv > data.utf8.csv
file -i reports the detected type and charset, and iconv converts between them. A byte-order mark at the start of a UTF-8 file can also add a stray character to the first header name; strip it before parsing. The desktop-app version of this symptom is covered in fix garbled CSV.
Desktop and browser options
On a desktop session, the standard choice is LibreOffice Calc, which on open shows a Text Import dialog where you set the separator and encoding explicitly โ the reliable path, and the same idea as changing a CSV delimiter. Gnumeric is a lighter alternative. If the file is too large for a spreadsheet, remember the sheet limit is 1,048,576 rows and 16,384 columns per Microsoft's documented Excel limits (Calc is comparable), so either split it or read it in a viewer. For a file you did not create and only need to inspect, the free CSV viewer or CSV analyzer runs in the browser with nothing to install โ useful on a headless server where you only have a browser.
Frequently Asked Questions
How do I open a CSV file in Linux?
A CSV is plain text: use less data.csv to page through it, head -n 5 data.csv to see the top, or open it in a desktop app such as LibreOffice Calc. When fields contain commas inside quotes, view it with a real CSV parser rather than splitting on the comma.
Why does awk -F, give the wrong number of columns?
awk -F, splits on every comma, but RFC 4180 allows a comma inside a double-quoted field. A row like "Doe, Jane",Paris is two CSV fields but three comma-separated fragments, so awk reports the wrong count. Use a quote-aware parser such as the Python csv module or csvkit.
How do I count rows in a CSV from the command line?
wc -l counts physical lines, not records. A line break inside a quoted field makes the file have more lines than records, and a missing final newline makes it short. For an exact record count, parse it with csvstat --count or the Python csv module.
How do I fix a garbled CSV in the terminal?
It is an encoding mismatch. file -i data.csv reports the detected type and charset; iconv -f LATIN1 -t UTF-8 in.csv > out.csv re-encodes a legacy file to UTF-8. Check the result with less before feeding it to another tool.
NoCodeCSV Team
Updated October 8, 2026 ยท Practical guides by the NoCodeCSV team.
Go further with AI data tools
NoCodeCSV handles the basics for free. When your data work grows, these tools pair well with it:
- Stack AI โ build AI workflows that process your CSVs automatically, end to end. Try Stack AI
- Softr โ turn your cleaned data into customer-facing apps and portals without code. Try Softr
- Toggl Track โ track time spent on data projects and client work. Try Toggl
Some links above are affiliate links โ if you buy through them we may earn a commission at no extra cost to you.
Inspect a CSV Without a Terminal
Upload any CSV and read it as a clean table in seconds. No signup needed.
Related reading
CSV Fundamentals โ other guides that pair well with this one.
- CSV vs Excel
- Why a CSV Can Be Bigger Than XLSX
- How to Open a CSV in R
- AI CSV Editor: Edit a CSV with Plain English
Browse all guides in the NoCodeCSV blog.