Let’s explore CSV (Comma-Separated Values) and TSV (Tab-Separated Values) files used in the world of data.

CSV (Comma-Separated Values):
CSV is a simple and widely used file format for storing tabular data (data organized in rows and columns). Here’s how it works:

  • Format: In a CSV file, each line represents a row of data, and within each line, different values (columns) are separated by commas.
  • Example:
  Name, Age, Occupation
  John, 25, Engineer
  Sarah, 30, Scientist
  Alex, 22, Student
  • Usage: CSV files are great for representing structured data, such as spreadsheets or databases. They are easy to create, edit, and share, making them a standard choice for data interchange.

TSV (Tab-Separated Values):
TSV is another format for storing tabular data, similar to CSV but using tabs as separators instead of commas.

  • Format: In a TSV file, tabs (not commas) separate values in each row.
  • Example:
  Name    Age    Occupation
  John    25     Engineer
  Sarah   30     Scientist
  Alex    22     Student
  • Usage: TSV files serve the same purpose as CSV files but are preferred when data may contain commas, as the use of tabs reduces the likelihood of conflicts.

Common Use Cases:

  • Data Storage: Both CSV and TSV files are used to store data in a format that is easy to read and understand, making them popular choices for databases and spreadsheets.
  • Data Exchange: These file formats are commonly used for exchanging data between different software applications, systems, or platforms. Many data analysis tools, programming languages, and spreadsheet software support CSV and TSV.
  • Web Applications: CSV and TSV files are often used in web applications for importing and exporting data. They provide a lightweight and portable way to transfer structured information.
  • Data Analysis: Analysts and data scientists frequently use CSV and TSV files as input for data analysis. Tools like Pandas in Python make it easy to work with these file formats.

In summary, CSV and TSV files are versatile and widely used for storing and exchanging structured data due to their simplicity, ease of use, and compatibility with various applications and tools.


“Let’s dive into the exciting world of working with CSV and TSV files! πŸš€ Here are some cool things you can do:

1. Importing Pandas:
First things first, we need a superhero tool called Pandas. It helps us analyze and play with data easily.

   import pandas as pd

2. Opening a Local CSV File:
Imagine your data as a treasure map. Pandas helps us read and understand it in a cool table format.

   df = pd.read_csv('path_of_file')

3. Opening a CSV File from an URL:
You can also fetch data from the internet! It’s like bringing in data from a magical online land.

   import requests
   from io import StringIO

   url = "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv"
   headers = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:66.0) Gecko/20100101 Firefox/66.0"}
   req = requests.get(url, headers=headers)
   data = StringIO(req.text)


4. Sep Parameter:
This is like telling Pandas how the data is separated. For regular CSV, it’s a comma, but for TSV (Tab-Separated Values), it’s a tab.

   pd.read_csv('file_name.tsv', sep='\t')

5. Index_col Parameter:
You can pick a special column to be the superhero index of your data.

   pd.read_csv('file_name.csv', index_col='any_input_column')

6. Header Parameter:
Choose how much information you want to see at the top. It’s like saying, “Show me the first 5 rows!”

   pd.read_csv('file_name.csv', header=5)

7. use_cols Parameter:
Sometimes, you only want specific columns, not everything. This helps you pick your favorite columns.

   pd.read_csv('file_name.csv', usecols=['important_column', 'column_name'])

8. Squeeze Parameter:
When you have just one column, Pandas can squish it into a neat series.

   pd.read_csv('file_name.csv', usecols=['column_name'], squeeze=True)

9. Skiprows/nrows Parameter:
Skip some rows if they are not important. It’s like skipping boring parts of a story.

   pd.read_csv('file_name.csv', nrows=100)

10. Encoding Parameter:
If your data has special characters, use this parameter to read it properly.

pd.read_csv('file_name.csv', encoding='latin-1')

And there you have it, a bunch of superhero moves to master CSV and TSV files! πŸ¦Έβ€β™‚οΈπŸ’»βœ¨”


SQL -> fetch data from the database

Data Gathering: CSV, JSON/SQL, fetch API, web scraping

when you fetch data from API, it will fetch in JSON/SQL files.

well I have data of train.json and world.sql

well if you want to code and data files, you can visit:



import pandas as pd

working with SQL with Python

Working with JSON

# read datapd.read_json(‘../input/working-with-jsonsql-file/train.json’)

read data from url


Working with SQL

!pip install mysql.connector

**you have to make database by using xampp. and connect with python.
# connector is used to make bridge between database and python.import mysql.connector

# connect python to database , host of our local site i.e localhost

conn = mysql.connector.connect(host=’localhost’,user=’root’,password=’ ‘,database=’world’)

df = pd.read_sql_query(“SELECT * FROM countrylanguage”,conn)


Leave a Reply

Your email address will not be published. Required fields are marked *