Computer Science
Which of the following function is used with the csv module in Python to read the contents of a csv file into an object ?
- readrow()
- readrows()
- reader()
- load()
Answer
reader()
Reason — In the CSV module in Python, the reader() function is used to read the contents of a CSV file into an object. This function returns a reader object which can be used to iterate over the rows of the CSV file, where each row is represented as a list of strings. This allows to process the data contained within the CSV file.
Related Questions
Write statements to open a binary file C:\Myfiles\Text1.txt in read and write mode by specifying file path in two different formats.
Which of the following Python modules is imported to store and retrieve objects using the process of serialization and deserialization ?
- csv
- binary
- math
- pickle
When a file is opened for output in write mode, what happens when
(i) the mentioned file does not exist
(ii) the mentioned file does exist ?
What role is played by file modes in file operations ? Describe the various file mode constants and their meanings.