CSV Files - CBSE Class 12 Computer Science Notes, Diagrams and Solved Questions

Read and write comma-separated tables with Python's csv module: opening with newline='', writer(), writerow() and writerows(), reader(), converting fields, and searching rows, including a user-id and password check.

In this chapter

  • What a CSV file is: rows, fields, header and delimiter
  • Opening and closing CSV files with the right mode and newline=''
  • Writing one row with csv.writer() and writerow()
  • Writing many rows with writerows(), and appending
  • Reading rows with csv.reader() and skipping the header
  • Searching rows: the user-id and password check
  • Processing CSV data: counts, toppers and copying rows