Why is the Delimiter = ","?

Why are we using comma “,” for the delimiter, but not dot “.”? I thought dots are the indicators of the end of sentences. Isn’t the “Delimiter” parameter to show the csv.reader where the end of sentence is? Does the csv.reader() somehow know where the end of sentence is?

The delimiter == ‘,’ is used when reading from csv files to get a separation of the different inputs, for eg. the column heads at the first line are separated by commas. It has not relation to the end of sentence when dealing with csv files. You may change it to ‘.’ if each input is separated with ‘.’
for that file, compared to ‘,’.

1 Like

Thanks @gent.spah! Then, how does the csv.reader know where the end of sentences are?

IIRC, the data in the CSV file is formatted such that each sentence is stored in its own row. The csv.reader iterates through the CSV one row at a time, and in each row, the words are separated by commas, which is why the delimiter is a comma.

1 Like

With the newline ‘\n’ charachter, when it detects it, its the end of the line.

This confused me as well when I opened the csv file using Excel. If it is opened in a txt format, the comma is clearly seen!

While CSV files are named for their comma-separated values format, it’s possible to use alternative delimiters by specifying them during file creation. However, since commas or tabs are the standard, deviating from these may not be advisable.

1 Like