Explain Reading CSV files with CSV.
Answer:
CSV files are handled using the csv module. The reader class from the module is used for reading from a csv file .
- At first, the csv file is opened in the read mode using the in-built function open( ).
- The open( ) function returns a file object.
- This file object is passed to the reader.
Example:
import
csv
f=open(
"values.csv"
,
'r'
)
output=csv.reader(f,delimiter=
','
)
for
row
in
output:
print(row)