Read CSV Files using built-in Python open() function

Here we are not using any third-party library in Python. We are just opening the file and reading it line by line using built-in Python open() function.

Python3




# using open function
 
file = open("data.csv")
 
for i in file:
    print(i)


Output:

Reading CSV files using open() function

How to Read CSV Files with NumPy?

In this article, we will discuss how to read CSV files with Numpy in Python. Reading CSV files using Python NumPy library helps in loading large amount of data quicker. Due to performance reason, NumPy is preferred while reading huge amount of data from CSV files.

Dataset in use:

Read CSV Files with NumPy

Similar Reads

Read CSV Files using built-in Python open() function

Here we are not using any third-party library in Python. We are just opening the file and reading it line by line using built-in Python open() function....

Read CSV files Using NumPy loadtxt() method

...

Read CSV files Using NumPy genfromtxt() method

To import data from a text file, we will use the NumPy loadtxt() method. To use this function, we need to make sure that the count of entries in each line of the text document should be equal. In Python, numpy.load() is used to load data from a text file, with the goal of being a quick read for basic text files....

Read CSV files Using Pandas read_csv() function

...

Read CSV files Using built-in Python csv module

The genfromtxt() method is used to import the data from a text document. We can specify how to handle the missing values if there are any....

Contact Us