First Step in Data World!

Ahmet Talha Bektaş
3 min readSep 19, 2022

--

The world is getting larger than we can see. Every single action is producing data. The world is so new place than our grandfathers know.

How will we be involved in this new Data World?

Datasets generally have several types. These are mainly: CSV files, Excel files, and SQL files.

If you want to practice, you can find my notebook on my GitHub or in my Kaggle.

Let’s Start with CSV files!

CSV means “Comma-separated values”. They are calling like that because in this type of file every value is separate with commas.

Like that :

How will we read CSV files?

The first thing we need is “pandas” library so we can easily add a pandas library like that:

import pandas as pd

in this code we are adding pandas library with “import pandas”, after that we are writing as pd because pandas are long so we chose shortly pd for pandas.

Let’s read the data! It is a very simple code. Just that:

df=pd.read_csv("yourfilename.csv")

Congratulations! You can read the data. If you write df (DataFrame) to your notebook you will see DataFrame.

How will we read Excel files?

We also need “pandas” library for reading again.

import pandas as pd

Then just read the data like that :

data=pd.read_excel("test_pandas.xlsm","Sheet1")

After the brackets first, you need to write the “file names” and after that the “sheet” of the data which you want to read.

As you can see, you read the excel files🎉

Congratulations, now you know how to read excel files with pandas.

How will we read SQL files?

In this case, we need two libraries: “pandas” and “sqlite3”.

import pandas as pd
import sqlite3

Then we need to connect with the database :

conn=sqlite3.connect("test_pandas.db")

So the next one is reading data :

sql_query="SELECT*FROM test"
data=pd.read_sql(sql_query,conn)

Let’s look at the data!

As you can see, you read the SQL🎉

Congratulations, now you know how to read SQL data.

That’s one small step for you, one giant leap for mankind.

Photo by History in HD on Unsplash

Conclusion

Now you can read CSV files, Excel files, and SQL files.

Yes, I can understand your question which is “What will you do after the reading data ?”.

If you want to know :

My next blog is “Our new friend is ‘EDA’ ”.

Author:

Ahmet Talha Bektaş

If you want to ask anything to me, you can easily contact me!

📧My email

🔗My LinkedIn

💻My GitHub

👨‍💻My Kaggle

📋 My Medium

--

--