To Import CSV data into your Python project, you should have your working directory set correctly first. If you have not done that, click here to read how to set your working folder in python.
So before I start, i know where is my working folder and where is my CSV file.
Do this, and I know I should place my CSV file at C:\Users\Public\Machine Learning
Pandas is an excellent library for data handling. If your python do not have pandas installed, do this in your terminal
Python Library that Import CSV
pip install pandas
Back to your editor or console, we are going to import panadas
import pandas as pd
Now we can use call the functions from pandas using “pd”
Importing CSV Data to Python
dataset = pd.read_csv(“Data.csv”)
This will set declare “dataset” as a variable in your project that equals to your data in CSV file
What we have just did is that we called pandas (pd) function name “read_csv”.
“Data.csv” is my csv file. Change it to your CSV file name, and this should work for you.
Visualize the CSV data you have imported
If you are using Anaconda Spyder, you should see your variables in the “variable explorer” section.
Double click the dataset you have just declared, and you should visualize your data.
Other Sections on Data Handling in Python
3.) How to Import CSV Data using Pandas