Professional Documents
Culture Documents
Basic Operations With CSV Files: CSV (Comma Separated Values) May Be A Simple File Format Accustomed To
Basic Operations With CSV Files: CSV (Comma Separated Values) May Be A Simple File Format Accustomed To
Working with CSV files isn’t that tedious task but it’s pretty straightforward.
However, counting on your workflow, there can become caveats that you
simply might want to observe out for.
If you’ve got a CSV file, you’ll open it in Excel without much trouble. Just open
Excel, open and find the CSV file to figure with (or right-click on the CSV file and
choose Open in Excel). After you open the file, you’ll notice that the info is
simply plain text put into different cells.
If you wish to save lots of your current workbook into a CSV file, you have got to
use the subsequent commands:
Importing Pandas
Firstly, we import the necessary dependencies such as Pandas Library of Python.
import pandas as pd
So, the dependency is imported, now we can load and read the dataset easily.
read-csv function
It is an important pandas function to read CSV files and do operations on
them.
This function helps us to load the file either from your local machine or
from any URL.
df = pd.read_csv('aug_train.csv')
print(df)
Program-1.
Program -2
Write a program to read from a CSV file Employee.Csv create a
dataframe from 8 but data frame should not use files column
header rather should use own column numbers as 0,1,2 and so on.
Output
Program -3.
Program to read from a CSV file employee. Csv and create a
DataFrame from it. Use Empno column as index labels
Output-
Program-4.
Program to read from a csv file employee. Csv and create a
DataFrame from it but data frame should not use files column
header rather should use on column reading as EmplD,
EmpName,Designation and salary.Also print the maximum salary
given to an employee
Output-
Program-5.
Write a program to read the records from file employee.Csv in
DataFrame and print the last two rows stored in the CSV file
Output:-