You are on page 1of 4

E

xperiment No: - 01(A)

NAME : Anjali Shinde


CLASS : SE
BATCH : B3
ROLL NO : EN2052

Aim:
Introduction to data analytics and Python fundamentals:
● Understanding the Data.

● Python Packages for Data Science.

● Importing and Exporting Data in Python.

● Getting Started Analyzing Data in Python.

● Accessing Databases with Python.

#"opening and closing the text file" #Reading of


entire text file text_file=open("AB.txt","r")
print ('The text file is:', text_file.read())
text_file.close()
=============== RESTART: C:/Users/admin/Desktop/Vaibhav/DAPR1.py =============== The text file
is: Name :- Jagtap Vaibhav
Class :- SE(E&TC) Roll
No :- EN2020
Name :- Jagtap Vaibhav

#Reading of one line at a time


text_file=open("AB.txt","r") print
(text_file.readline())
print (text_file.readline())
text_file.close()
=============== RESTART: C:/Users/admin/Desktop/Vaibhav/DAPR1.py ===============
Name :- Jagtap Vaibhav

#Reading of perticular characters from line


text_file=open("AB.txt","r")
print (text_file.read(3))
text_file.close()
=============== RESTART: C:/Users/admin/Desktop/Vaibhav/DAPR1.py =============== Nam
#Make a list of lines present in a text file
text_file=open("AB.txt","r") lines=text_file.readlines()
print('lines are:',lines)
print ('total number of lines in text file is;',len(lines)) for lines
in lines:
print(lines)
text_file.close()

=============== RESTART: C:/Users/admin/Desktop/Vaibhav/DAPR1.py ===============

lines are: ['Name :- Jagtap Vaibhav\n', 'Class :- SE(E&TC)\n', 'Roll No :- EN2020'] total number of
lines in text file is; 3
Name :- Jagtap Vaibhav
Class :- SE(E&TC)

Roll No :- EN2020

#Writing to a text file


f=open("AB.txt","w")
f.write("Hello to all")
f.close()

Hello to all

#Enter String at Run Time


f=open("AB.txt","w") s=input("Enetr
String=") f.write(s)
f.close()

============== RESTART: C:/Users/admin/Desktop/Vaibhav/WRITING.py ============== Enetr


String=Vaibhav Jagtap

Vaibhav Jagtap
#Multiple lines at a time
f=open("AB.txt","w")
n=int(input("How Many Lines="))
for i in range(n):
s=input("enter String:-")
f.write(s+"\n")
f.close()

============== RESTART: C:/Users/admin/Desktop/Vaibhav/WRITING.py ==============

How Many Lines=2


enter String:-Vaibahv
enter String:-Jagtap
Vaibahv
Jagtap
Experiment No: - 01(B)

#Exporting data import


pandas as pd

df=pd.DataFrame({"Name":["SE","TE","BE"], "Class":[1,2,3],
"score":[77,66,55]})
print(df)
df.to_csv("vaibhav.csv")

======== RESTART: C:/Users/Desktop/DA LAB/vaibhav.py ========

Name Class score

0 SE
1
77
1 TE

#importing data
import pandas as pd

df=pd.read_csv(‘vaibhav.csv’)
print(df)

======= RESTART: C:/Users/VAIBHAV/OneDrive/Desktop/New folder/vaibhav1.py ====== Unnamed: 0


Name Class score

0 0 SE 1 7
7
1 1 TE 2 6
6
2 2 BE 3 55

You might also like