
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python - Read csv file with Pandas without header?
To read CSV file without header, use the header parameter and set it to “None” in the read_csv() method.
Let’s say the following are the contents of our CSV file opened in Microsoft Excel −
At first, import the required library −
import pandas as pd
Load data from a CSV file into a Pandas DataFrame. This will display the headers as well −
dataFrame = pd.read_csv("C:\Users\amit_\Desktop\SalesData.csv")
While loading, use the header parameter and set None to load the CSV without header −
pd.read_csv("C:\Users\amit_\Desktop\SalesData.csv", header=None)
Example
Following is the code −
import pandas as pd # Load data from a CSV file into a Pandas DataFrame dataFrame = pd.read_csv("C:\Users\amit_\Desktop\SalesData.csv") print("\nReading the CSV file...\n",dataFrame) # Load data from a CSV file and hide the header dataFrame = pd.read_csv("C:\Users\amit_\Desktop\SalesData.csv", header=None) print("\nReading the CSV file (without header)...\n",dataFrame)
Output
This will produce the following output −
Reading the CSV file... Car Reg_Price Units 0 BMW 2500 100 1 Lexus 3500 80 2 Audi 2500 120 3 Jaguar 2000 70 4 Mustang 2500 110 Reading the CSV file (without header)... 0 1 2 0 Car Reg_Price Units 1 BMW 2500 100 2 Lexus 3500 80 3 Audi 2500 120 4 Jaguar 2000 70 5 Mustang 2500 110
- Related Articles
- How to read a Pandas CSV file with no header?
- How to read CSV file in Python?
- Python Pandas- Create multiple CSV files from existing CSV file
- Python - Read all CSV files in a folder in Pandas?
- Python - How to write pandas dataframe to a CSV file
- Writing a Pandas DataFrame to CSV file
- How to read data from *.CSV file using JavaScript?
- How to read data from .csv file in Java?
- Python Pandas - Read data from a CSV file and print the ‘product’ column value that matches ‘Car’ for the first ten rows
- Rename column name with an index number of the CSV file in Pandas
- Print “Hello World” without using any header file in C
- Python Program to open a file in the read-write mode without truncating the file
- How to read the data from a CSV file in Java?\n
- Reading and Writing CSV File using Python
- How to convert CSV File to PDF File using Python?

Advertisements