SlideShare a Scribd company logo
 Files are named locations on disk to store related
information. They are used to permanently store
data in a non-volatile memory.
 The following is the order operation on files:
1. Open
2. Read or Write
3. Close
 open() function is used to open a file, which
returns a file object – used to call other support
methods associated with it.
fileObject = open(file_name [, access_mode][, buffering])
 close() method is used to close the file.
fileObject.close()
 file.name - Returns name of the file.
 file.mode - Returns access mode with which file
was opened.
 file.closed - Returns true if file is closed, false
otherwise.
 fileObject.read([count])
 fileObject.readline()
 fileObject.readlines()
 fileObject.write()
 fileObject.tell()
 fiileObject.seek(offset)
 readlines() method appends each line to the list and then
returns the entire list it will be time-consuming if the file size
is extremely large say in GB.
 The input() method of fileinput module can be used to read
large files.
fileinput.input(“filename”)
 Open the file in a ‘with’ block as it automatically closes the
file as soon as the entire block executes.
with open(“filename”) as file
 JavaScript Object Notation(JSON) is a script file
which is made of text in a programming language is
used to store and transfer the data.
 The text in JSON is done through quoted-string which
contains the value in key-value mapping within { }.
 Python has a built-in package called json, which can be
used to work with JSON data.
 The JSON package has json.load() function that loads the JSON content
from a JSON file into a dictionary.
json.load(file_object)
 The JSON package in Python has a function called json.dumps() that helps
in converting a dictionary to a JSON object
json_object = json.dumps(dictionary, indent)
file_object.write(json_object)
 Another way of writing JSON to a file is by using json.dump() method.
json.dump(dictionary,file_object)
 XML stands for eXtensible Markup Language. XML is
a text-based markup language designed to store and
transport data.
 Python comes with the ElementTree library that
provides several functions to read and manipulate the
XMLs.
 To use the ElementTree module, we need to import
xml.etree.ElementTree
 To load XML file use parse method.
ET.parse(source,parser)
 To know the root element use getroot().
 In order to display the HTML file as a python output, we will
be using the codecs library. This library is used to open files
which have a certain encoding. It takes a
parameter encoding which makes it different from the built-in
open() function.
 In Python, webbrowser module provides a high-level
interface which allows displaying Web-based documents to
users. The webbrowser module can be used to launch a
browser in a platform-independent manner
 Excel is a spreadsheet application which is developed
by Microsoft. It is an easily accessible tool to organize,
analyze, and store the data in tables.
 Python provides xlrd and openpyxl modules for excel
spreadsheet.
pip install xlrd
pip install openpyxl
Files.pptx

More Related Content

Similar to Files.pptx

files.pptx
files.pptxfiles.pptx
files.pptx
KeerthanaM738437
 
FIle Handling and dictionaries.pptx
FIle Handling and dictionaries.pptxFIle Handling and dictionaries.pptx
FIle Handling and dictionaries.pptx
Ashwini Raut
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptx
armaansohail9356
 
Python-FileHandling.pptx
Python-FileHandling.pptxPython-FileHandling.pptx
Python-FileHandling.pptx
Karudaiyar Ganapathy
 
File Handling
File HandlingFile Handling
File Handling
AlgeronTongdoTopi
 
File Handling
File HandlingFile Handling
File Handling
AlgeronTongdoTopi
 
FILE HANDLING in python to understand basic operations.
FILE HANDLING in python to understand basic operations.FILE HANDLING in python to understand basic operations.
FILE HANDLING in python to understand basic operations.
ssuser00ad4e
 
INput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptxINput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptx
AssadLeo1
 
Python files / directories part15
Python files / directories  part15Python files / directories  part15
Python files / directories part15
Vishal Dutt
 
Chapter - 5.pptx
Chapter - 5.pptxChapter - 5.pptx
Chapter - 5.pptx
MikialeTesfamariam
 
CHAPTER 2 - FILE HANDLING-txtfile.pdf is here
CHAPTER 2 - FILE HANDLING-txtfile.pdf is hereCHAPTER 2 - FILE HANDLING-txtfile.pdf is here
CHAPTER 2 - FILE HANDLING-txtfile.pdf is here
sidbhat290907
 
File Handling in C
File Handling in CFile Handling in C
File Handling in C
VrushaliSolanke
 
File handling
File handlingFile handling
File handling
Swarup Kumar Boro
 
Python Session - 5
Python Session - 5Python Session - 5
Python Session - 5
AnirudhaGaikwad4
 
File Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handlingFile Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handling
abdulsamadbrohi461
 
7 Data File Handling
7 Data File Handling7 Data File Handling
7 Data File Handling
Praveen M Jigajinni
 
Php files
Php filesPhp files
Php files
kalyani66
 
File Handling
File HandlingFile Handling
File Handling
TusharBatra27
 
Files nts
Files ntsFiles nts
Files nts
kalyani66
 
working with files
working with filesworking with files
working with files
SangeethaSasi1
 

Similar to Files.pptx (20)

files.pptx
files.pptxfiles.pptx
files.pptx
 
FIle Handling and dictionaries.pptx
FIle Handling and dictionaries.pptxFIle Handling and dictionaries.pptx
FIle Handling and dictionaries.pptx
 
File handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptxFile handling in C hhsjsjshsjjsjsjs.pptx
File handling in C hhsjsjshsjjsjsjs.pptx
 
Python-FileHandling.pptx
Python-FileHandling.pptxPython-FileHandling.pptx
Python-FileHandling.pptx
 
File Handling
File HandlingFile Handling
File Handling
 
File Handling
File HandlingFile Handling
File Handling
 
FILE HANDLING in python to understand basic operations.
FILE HANDLING in python to understand basic operations.FILE HANDLING in python to understand basic operations.
FILE HANDLING in python to understand basic operations.
 
INput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptxINput output stream in ccP Full Detail.pptx
INput output stream in ccP Full Detail.pptx
 
Python files / directories part15
Python files / directories  part15Python files / directories  part15
Python files / directories part15
 
Chapter - 5.pptx
Chapter - 5.pptxChapter - 5.pptx
Chapter - 5.pptx
 
CHAPTER 2 - FILE HANDLING-txtfile.pdf is here
CHAPTER 2 - FILE HANDLING-txtfile.pdf is hereCHAPTER 2 - FILE HANDLING-txtfile.pdf is here
CHAPTER 2 - FILE HANDLING-txtfile.pdf is here
 
File Handling in C
File Handling in CFile Handling in C
File Handling in C
 
File handling
File handlingFile handling
File handling
 
Python Session - 5
Python Session - 5Python Session - 5
Python Session - 5
 
File Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handlingFile Handlingb in java. A brief presentation on file handling
File Handlingb in java. A brief presentation on file handling
 
7 Data File Handling
7 Data File Handling7 Data File Handling
7 Data File Handling
 
Php files
Php filesPhp files
Php files
 
File Handling
File HandlingFile Handling
File Handling
 
Files nts
Files ntsFiles nts
Files nts
 
working with files
working with filesworking with files
working with files
 

More from Govardhan Bhavani

Angular Application Setup.pptx
Angular Application Setup.pptxAngular Application Setup.pptx
Angular Application Setup.pptx
Govardhan Bhavani
 
Pandas.pptx
Pandas.pptxPandas.pptx
Pandas.pptx
Govardhan Bhavani
 
NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
Govardhan Bhavani
 
ExpressJS and REST API.pptx
ExpressJS and REST API.pptxExpressJS and REST API.pptx
ExpressJS and REST API.pptx
Govardhan Bhavani
 
NodeJS.pptx
NodeJS.pptxNodeJS.pptx
NodeJS.pptx
Govardhan Bhavani
 
Angular.pptx
Angular.pptxAngular.pptx
Angular.pptx
Govardhan Bhavani
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
Govardhan Bhavani
 
Maven.pptx
Maven.pptxMaven.pptx
Maven.pptx
Govardhan Bhavani
 
Configure & Version Control-Git.pptx
Configure & Version Control-Git.pptxConfigure & Version Control-Git.pptx
Configure & Version Control-Git.pptx
Govardhan Bhavani
 
DevOps.pptx
DevOps.pptxDevOps.pptx
DevOps.pptx
Govardhan Bhavani
 
Agile XP.pptx
Agile XP.pptxAgile XP.pptx
Agile XP.pptx
Govardhan Bhavani
 
Ajax
AjaxAjax
Ruby
RubyRuby
PHP
PHPPHP
CSS
CSSCSS
Unit 1part-2 forms & frames
Unit 1part-2 forms & framesUnit 1part-2 forms & frames
Unit 1part-2 forms & frames
Govardhan Bhavani
 
Unit 1 (part-1, basic tags)
Unit 1 (part-1, basic tags)Unit 1 (part-1, basic tags)
Unit 1 (part-1, basic tags)
Govardhan Bhavani
 

More from Govardhan Bhavani (17)

Angular Application Setup.pptx
Angular Application Setup.pptxAngular Application Setup.pptx
Angular Application Setup.pptx
 
Pandas.pptx
Pandas.pptxPandas.pptx
Pandas.pptx
 
NumPy.pptx
NumPy.pptxNumPy.pptx
NumPy.pptx
 
ExpressJS and REST API.pptx
ExpressJS and REST API.pptxExpressJS and REST API.pptx
ExpressJS and REST API.pptx
 
NodeJS.pptx
NodeJS.pptxNodeJS.pptx
NodeJS.pptx
 
Angular.pptx
Angular.pptxAngular.pptx
Angular.pptx
 
JavaScript.pptx
JavaScript.pptxJavaScript.pptx
JavaScript.pptx
 
Maven.pptx
Maven.pptxMaven.pptx
Maven.pptx
 
Configure & Version Control-Git.pptx
Configure & Version Control-Git.pptxConfigure & Version Control-Git.pptx
Configure & Version Control-Git.pptx
 
DevOps.pptx
DevOps.pptxDevOps.pptx
DevOps.pptx
 
Agile XP.pptx
Agile XP.pptxAgile XP.pptx
Agile XP.pptx
 
Ajax
AjaxAjax
Ajax
 
Ruby
RubyRuby
Ruby
 
PHP
PHPPHP
PHP
 
CSS
CSSCSS
CSS
 
Unit 1part-2 forms & frames
Unit 1part-2 forms & framesUnit 1part-2 forms & frames
Unit 1part-2 forms & frames
 
Unit 1 (part-1, basic tags)
Unit 1 (part-1, basic tags)Unit 1 (part-1, basic tags)
Unit 1 (part-1, basic tags)
 

Recently uploaded

Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 

Recently uploaded (20)

Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 

Files.pptx

  • 1.
  • 2.  Files are named locations on disk to store related information. They are used to permanently store data in a non-volatile memory.  The following is the order operation on files: 1. Open 2. Read or Write 3. Close
  • 3.  open() function is used to open a file, which returns a file object – used to call other support methods associated with it. fileObject = open(file_name [, access_mode][, buffering])  close() method is used to close the file. fileObject.close()
  • 4.  file.name - Returns name of the file.  file.mode - Returns access mode with which file was opened.  file.closed - Returns true if file is closed, false otherwise.
  • 5.  fileObject.read([count])  fileObject.readline()  fileObject.readlines()  fileObject.write()
  • 7.  readlines() method appends each line to the list and then returns the entire list it will be time-consuming if the file size is extremely large say in GB.  The input() method of fileinput module can be used to read large files. fileinput.input(“filename”)  Open the file in a ‘with’ block as it automatically closes the file as soon as the entire block executes. with open(“filename”) as file
  • 8.  JavaScript Object Notation(JSON) is a script file which is made of text in a programming language is used to store and transfer the data.  The text in JSON is done through quoted-string which contains the value in key-value mapping within { }.  Python has a built-in package called json, which can be used to work with JSON data.
  • 9.  The JSON package has json.load() function that loads the JSON content from a JSON file into a dictionary. json.load(file_object)  The JSON package in Python has a function called json.dumps() that helps in converting a dictionary to a JSON object json_object = json.dumps(dictionary, indent) file_object.write(json_object)  Another way of writing JSON to a file is by using json.dump() method. json.dump(dictionary,file_object)
  • 10.  XML stands for eXtensible Markup Language. XML is a text-based markup language designed to store and transport data.  Python comes with the ElementTree library that provides several functions to read and manipulate the XMLs.  To use the ElementTree module, we need to import xml.etree.ElementTree
  • 11.  To load XML file use parse method. ET.parse(source,parser)  To know the root element use getroot().
  • 12.
  • 13.  In order to display the HTML file as a python output, we will be using the codecs library. This library is used to open files which have a certain encoding. It takes a parameter encoding which makes it different from the built-in open() function.  In Python, webbrowser module provides a high-level interface which allows displaying Web-based documents to users. The webbrowser module can be used to launch a browser in a platform-independent manner
  • 14.  Excel is a spreadsheet application which is developed by Microsoft. It is an easily accessible tool to organize, analyze, and store the data in tables.  Python provides xlrd and openpyxl modules for excel spreadsheet. pip install xlrd pip install openpyxl