Sei sulla pagina 1di 3

Files: File is a collection of similar data having following characterstics

1.Location
2.Name
3.Extension

Directory:
It is a collection of sub-directories or files or both
It do have 2 characterstics
1.Location
2.Name

*****
OS:OS is module where we can work with files n directories in our system

*****we can work with with the files in python using following functions
1.open()
2.read()
3.write()
4.close()
5.read_lines()

The foolowing are modes used in files


1.r- for read
2.w- for write
3.a-for append
4.rb-for read bytes
5.wb-for write bytes

NOTE:rb,wb are used to worked with binary files like audio,video,image etc.

CSV FILES:
comma seperated values
In python a data set can be collected n processed using following formats:
1.CSV
2.XML
3.JSON-java script object notation

The common format to use the data n their values processed using above mentioned
modules/libraries

1.CSV is a data set file to process sample data seperated by delimileter(seperator)


called either tabs/newlines/hifens n commas

Mainly used in data set collections n processing

2.XML:Extensible markup language its a common format exchange across web


applications
XML is for data representataion

NOTE:It's not like html to present data.

Parsing:It is the approach to extract data from XML files

3.JSON: java script object notation recently using for web API (application
programming
Interface) between web services n websites.
*****JSON is dictionary of dictionary's.

NOTE:JSON,CSV,XML are files


CSV
name,age,gender,phone,email,course,university
sravs,20,female,9119210879,prattikanthamsravani@gmail.com,cse,amity,

******office 360 use this rather than ppt

XML:html is for appearnce


xml is for data representation-is like database,its not a editable format

MML(mathematical markup lang):for symbols

JSON: type states.JSON

DATE:

OS: In order to access resource from a system we use python's bulid in module OS
it's not specific to any OS
We can walk through individual files n directories through specific functions

Methods:
1.path()-its a combination of name,location,extension
2.getcwd()-current working directory
3.chwd()-change working directory
4.mkdir()-make a directory(folder)
5.makedirs()-it's a creating directorie's(more than one folder),hierarchial folders
6.rmdir()-means remove directory-to delete a single folder use rmdir
7.removedirs()-remove directory's-to remove multiple folders n files
8.walk()-internally searching for folders n files
************9.split()-divide into 3-location,name,extension
10.splitext()-name,extension
11.join()-to join paths-path is not a string
12.listdir()-list of directories(specific folder search)
13.environ.set-speciaaaly used for database,email n passowords
14.environ.get
search for environmental variables in google
its a environmental varaiables can be used to work with environ

REGULAR EXPRESSION:Regular expression is used to validate inputs/data according to


the given pattern

PYTHON'S IN BUILT LIBRRARY KNWN AS RE:used to create pattrens

NOTE: regular expressions concern to the string format


Step1: creating a pattern
Step2:.finding the mathchers by comparing with our input
Step3:If the matches are found they will return span(row/columns/position)

NOTE:Pattrens are created using raw strings

NOTE2:Regular expressions are used by


qualifiers n quantifiers
Qualifiers: use []-this is called as range
()-set
{}-list
/d-digits
/D-other than numbers
.(fullstop)-all characters except new line
/w white spaces
$-end
^ called as charat-starting points(start)
Quantifiers:
+(one or more)
?(0 or 1)
*(0 or more)
Quantifiers are used for repition for a given pattern

re(regular)is used for creating editors


re used two important methods
1.compile()
2.matches()
3.find()-return no of spans

name [A-Za-z]-([] it is a range )

passowrd [A-Za-z0-9._-@]+(one or more)-min(8 ) max(55)

age /d(18,38) d for digits

phone /d(10,11)+

email-id [a-z0-9_.]@{gmail,yahoo mail}.{com,in}

url https?-(?-reptesnts use it either 0 or 1 time)


https?www?[a-z]

CONTEXT MANAGER:
Context manager is used for files and connections(database/network connections)
It is a good practice whenever we are working with context manager in files and
database works

>>>with open(connection) as var:


statements
which will automatically close the connection or file whenever we come out from
indentation
block.

Potrebbero piacerti anche