How to read a CSV file with pandas in Python: a guide
Reading data from a CSV file is almost always the first step of any analysis in Python, and the pandas library makes that task fast and reliable. With just a few lines of code you can load thousands of records, handle different separators and accents, and be ready to explore your data. Below is the full path, from zero to your first exploration, with the most common errors already solved.
Prerequisites
- Python 3.9 or higher installed on your computer.
- The pandas library, which you install with
pip install pandas. - A sample CSV file — in this guide we use
vendas.csv. - An editor or notebook of your choice: VS Code, Jupyter or the command line.
Step 1: Install and import pandas
If you don't have pandas installed yet, start by installing it from the terminal. Then import the library at the top of your script using the short name pd, a convention that almost the entire Python community follows. This keeps your code shorter and easier to read.

pip install pandas
import pandas as pd
Step 2: Read the CSV file with read_csv
The read_csv function reads the file and returns a DataFrame, which is simply a table with rows and columns. In the simplest case, you only need to pass the file name. The head method shows just the first five rows, enough to confirm the file was read as expected.
df = pd.read_csv("vendas.csv")
print(df.head())
If the file is in another folder, pass the full path, for example "C:/dados/vendas.csv". Note that we use the forward slash, which works on every system.
Step 3: Adjust separator, accents and decimals
Many CSV files created in Europe use a semicolon as the column separator and a comma as the decimal separator. If all the columns appear stuck together in one, or the accents look wrong, adjust these three parameters.
df = pd.read_csv(
"vendas.csv",
sep=";",
decimal=",",
encoding="utf-8",
)
If you still see strange accents, try encoding="latin-1", very common in files exported from Excel.
Tip: open the file in a plain text editor before reading it. Seeing the first line immediately tells you the separator and whether there is a header.
Step 4: Do a first exploration
After reading the data, confirm it looks right with three very useful commands. head shows the first rows, info summarizes each column's type and how many values it has, and describe gives quick statistics for the numeric columns.
print(df.head())
print(df.info())
print(df.describe())
Step 5: Read only the columns you need
For large files, reading only the columns you need saves memory and makes everything faster. Use the usecols parameter with the list of columns you want to keep.
df = pd.read_csv(
"vendas.csv",
sep=";",
usecols=["data", "produto", "total"],
)
Verify the result
To be sure the read worked, check the number of rows and columns with df.shape, which returns a pair in the format (rows, columns). Also check the types with df.dtypes: a values column should appear as int64 or float64, not as object, which means text.
print(df.shape)
print(df.dtypes)
If a column that should be numeric shows up as text, the cause is almost always the decimal separator. Go back to Step 3 and review the decimal parameter.
Conclusion
With read_csv and a handful of parameters you can already load almost any CSV file in Python reliably. The natural next step is to clean the data: handle missing values, remove duplicates and convert dates to the correct type. Which CSV file will be the first you open with pandas?