Introduction to Files and Text Files - CBSE Class 12 Computer Science Notes, Diagrams and Solved Questions

Text, binary and CSV files; absolute and relative paths; the six text-file modes; with; writing and reading lines; moving the file pointer with seek and tell; and board-style counting and copying programs.

In this chapter

  • Why files are needed, and text, binary and CSV files
  • Absolute and relative paths
  • Opening with r, r+, w, w+, a, a+, closing, and the with clause
  • Writing with write() and writelines()
  • Reading with read(), readline(), readlines() and a for loop
  • The file pointer: seek() and tell()
  • Counting words, lines and vowels, and copying selected lines