ItSolutionStuff.com

Python Read CSV File Without Header Example

By Hardik Savani • October 30, 2023
Python

Hi Artisan,

In this tutorial, you will discover python read csv file without header. we will help you to give an example of how to read csv file without header in python. you can see python read csv file no header. I explained simply step by step read csv file without header python. Here, Create a basic example of read csv file skip header python.

In this example, we will take one demo.csv file with ID, Name and Email fields. Then, we will use open(), next() and reader() functions to read csv file data without header columns fields.

I will give you one example for reading csv file without header in python, so Without any further ado, let's see below code example:

You can use these example with python3 (Python 3) version.

Example:

main.py

from csv import reader
    
# skip first line from demo.csv
with open('demo.csv', 'r') as readObj:
  
    csvReader = reader(readObj)
    header = next(csvReader)
  
    # Check file as empty
    if header != None:
        # Iterate over each row after the header in the csv
        for row in csvReader:
            # row variable is a list that represents a row in csv
            print(row)

Output:

['1', 'Hardik Savani', 'hardik@gmail.com']
['2', 'Vimal Kashiyani', 'vimal@gmail.com']
['3', 'Harshad Pathak', 'harshad@gmail.com']

Header Was:
['ID', 'Name', 'Email']

Tags: Python
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Write CSV File in Python?

Read Now →

How to Add Header in CSV File using Python?

Read Now →

How to Write Multiple Rows in CSV using Python?

Read Now →

Python Write CSV File from List Example

Read Now →

How to Create CSV File in Python?

Read Now →

How to Check If a List is Empty or Not in Python?

Read Now →

Python Read Text File into List Example

Read Now →

Python Delete Files Matching Pattern Example

Read Now →

Python Get File Extension from Filename Example

Read Now →

Python List All Dates Between Two Dates Example

Read Now →

How to Compare Two Dates in Python?

Read Now →

How to Check if Today is Saturday or not in Python?

Read Now →

Python Subtract Seconds from DateTime Example

Read Now →

Python PUT Request with Parameters Example

Read Now →