following data: Roll No Name Favorite Sports Address 12101 Nivetha “Cricket”, “ Football” Mylapore Chennai 12102 Lavanya “Basketball”, “ Cricket” Adyar Chennai 12103 Ram “Soccer”, “ Hockey” Gopala puram Chennai It should be written in csv file as RollNo, Name, FavoriteSports, Address 12101, Nivetha,””” Cricket ””,”” Football ”””, Mylapore chennai 12102, Lavanya,””” Basketball ””,”” Cricket ”””, Adyar chennai 12103, Ram,””” Soccer””,”” Hockey”””, Gopalapuram chennai The output will be 12th Computer Chapter - - Python and CSV Files Roll No 12101 12102 12103 Name Favorite Sports Address Nivetha "Cricket", "Football" "Basketball", "Cricket" Adyar, Chennai Gopalapuram, Chennai "Soccer", "Hockey" Mylapore, Chennai Lavanya Ram Fig . . CSV Field Data with Double quotes in Excel . .
Rules to be followed to format data in a CSV file . Each record (row of data) is to be located on a separate line, delimited by a line break by pressing enter key. For example: xxx,yyy denotes enter Key to be pressed . The last record in the file may or may not have an ending line break.
For example: ppp, qqq yyy, xxx . There may be an optional header line appearing as the first line of the file with the same format as normal record lines. The header will contain names corresponding to the fields in the file and should contain the same number of fields as the records in the rest of the file. For example: , , aaa,bbb,ccc zzz,yyy,xxx CRLF ( Carriage Return and Line Feed) 12th Computer Chapter - - .
Within the header and each record, there may be one or more fields, separated by commas. Spaces are considered part of a field and should not be ignored. The last field in the record must not be followed by a comma. For example: Red , Blue .
Each field may or may not be enclosed in double quotes. If fields are not enclosed with double quotes, then double quotes may not appear inside the fields. For example: "Red","Blue","Green" #Field data with doule quotes Black,White,Yellow #Field data without doule quotes . Fields containing line breaks