CSV file reading in Python

Aniket Kale
Jul 30, 2017 · 2 min read

Most of the times data scientist deals with the CSV files. In python, we have in build libraries in which we can use the in build functions to load the files and perform the operations.

However, Today we are going to see the CSV file loading using python without libraries.

After loading the file, we can see the out put in window with a records(one row only).

Convert the string into the float:

Now we have to convert the strings values of the records into the float and integer values. since we are dealing with numeric records.

Convert the string into the integer:

Now we have to convert the class variables into the integer. in scikit learn we have one hot encoding to covert the class variables into the integer datatype.

Function

Result:

Conclusion: In this article, we have learned how to load the csv files and convert the numeric values into the float and integer before feeding to machine learning algorithm.

Reference:

Book: Machine learning algorithm from scratch.