| 1. |
Write the rules to be followed to format the data in a CSV file? |
|
Answer» Rules to be followed to format data in a CSV file: (i) 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 (ii) The last record in the file may or may not have an ending line break. For example: PPP, qqq yyy,xxx (iii) 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: field_ name 1,field_name 2,field_name_3 aaa,bbb,ccc zzz,yyy,xxx CRFF( Carriage Return and Line feed) (iv) 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 (v) 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 double quotes Black,White,Yellow #Field data without double quotes (vi) Fields containing line breaks (CRLF), double quotes, and commas should be enclosed in double-quotes. For example: Red, “;:Blue CRLF #comma itself is a field value, so it is enclosed with double quotes Red, Blue, Green (vii) If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be preceded with another double quote. For example: “Red, ” “Blue1: “Green” , #since double quotes is a field value it is enclosed with another double quotes,, White |
|