Introduction

File handling is an essential part of programming and is used for reading and writing files in computer systems. Python, being a high-level programming language, provides powerful and easy to use functions and modules for handling files. This tutorial will teach you the basics of file handling in Python. This tutorial is suitable for beginners and anyone who wants to learn about file handling with Python. So, let's get started!

Table of Contents :

  • File handling in Python
  • Different File handling operations in python
    • File operations for text files
    • File operations for json files
    • File operations for CSV files
    • Directory operations

File handling in Python :

  • The process of reading and writing data to files is called file handling.
  • We can perform read/write operations on different types of files in python e.g. 
    • text files
    • json files
    • csv files etc.
  • Python has a separate module for working with json files.
  • Similarly there is separate package for csv files in python. 

Different File handling operations in python

  • Here is a list of different file handling operations that we can perform on text files, directories, json files and csv files.
  • We have separate tutorials on each of these topics.
  • This list can be treated as an index of our tutorials related to file handling in python.

 

File operations for text files :

 

File operations for json files :

 

File operations for CSV files :

 

Directory operations :


 

Prev. Tutorial : Timezones

Next Tutorial : Creating a File