Data Structure and Algorithm using Python
PROGRAMMING ESSENTIALS IN PYTHON
File Manipulation
Peter Lo
File
There are two separate types of files that Python handles: Binary file Text files.
Knowing the difference between the two is important because of how they are handled.
Programming Essentials in Python @ Peter Lo 2022
2
Binary File
Most files that you use in your computer are binary files. For example, Microsoft Word .doc file is a binary file, even if it has text in it.
Other examples of binary files include:
Image files including .jpg, .png, .bmp, .gif, etc.
Database files including .mdb, .frm, and .sqlite
Documents including .doc, .xls, .pdf, and others.
That's because these files all have requirements for special handling and require a specific type of software to open it. For example, you need Excel to open an .xls file
Programming Essentials in Python @ Peter Lo 2022
3
Text File
A text file has no specific encoding and can be opened by a standard text editor without any special handling.
Every text file must adhere to a set of rules:
Text files have to be readable as is. They can contain a lot of special encoding, especially in HTML or other markup languages, but you'll still be able to tell what it says
Data in a text file is organized by lines. In most cases, each line is a distinct element, whether it's a line of instruction or a command.
Text files have some unseen character at the end of each line which lets the text editor know that there should be a new line. In Python, it is denoted by the "\n".
Programming Essentials in Python @ Peter Lo 2022
4
Comma Separated Value (CSV) Text File
A CSV file is a comma separated values file commonly used by spreadsheet programs such as Microsoft Excel.
It contains plain text data sets separated by commas with each new line in the CSV file representing a new database row and each database row consisting of one or more fields separated by a comma.
Programming Essentials in Python @ Peter Lo 2022
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- data structure diagram
- using python in bash
- using python on windows 10
- sum of squared error using python functions
- data collection and data analysis
- install jupyter using python 3 8
- using python functions
- using python as a calculator
- using python in cmd
- data structure using java
- using python in linux
- using python in command line