CSV looks trivial until a field contains a comma, a quote or a newline. Implement a parser without the csv module:
parse_csv(text, delimiter=",") returns a list of rows (lists of strings):
\n or \r\n. A final trailing newline doesn't create an extra empty row." is quoted: it may contain delimiters and newlines, "" inside it means a literal quote, and it ends at the next lone ". An unterminated quoted field raises ValueError." in the middle of an unquoted field is just a character.[""].Then implement to_csv(rows, delimiter=","): quote a field (doubling inner quotes) only if it contains the delimiter, a quote, \n or \r. Join fields with the delimiter and rows with \n.