Data file handling in python

Preview




What is a data file

A data file is a collection of data (bytes) stored on some storage device like hard-disk, CD, pen drive etc.

Types of data file

There are two types of data files

  • Text Files
  • Binary Files

1. Text files

A text files stores information in plain text (ASCII or Unicode characters) . In text files, each line of text is terminated with a special character known as EOL (end of Line) character. The text files are of following types :

i. Regular Text files. These text files store the text in the same form as typed by the user. These files have a file extension as .txt.

ii. Delimited Text files. These text files use  a specific character to separate the values in file Most commonly used characters are tab or comma after every value.

When a tab character is used to separate the values, these are called TSV files(Tab Separated Values) files. These files can take the extension as .txt or .csv.

When the comma is used to separate the values , these are called CSV files ( Comma Separated Values) files. These files have the extension as .csv.

2. Binary Files

A binary file stores the information in the form of a stream of bytes. Binary file contains information in the same format in which the information is held in memory. Binary files are processed faster than text files.

 




Lesson tags: Data file Handling in Python
Back to: Python Programming Tutorial