Q:

CSV with \n\r in lines - how to define a line end?`

I have very big CSV with 244 columns and 4000 rows.
There are a lot of \n\r, so when I try to split it with this (to find the end of a line) I get around 9000 rows instead of my wished 4000.
So how to determine which \n\r is within text or maybe at the end of a cell - and which is a definitive end of a line?

A:

When CSV file has data in column which is either \n,\r or , around these values usually put quotes. To correctly prase CSV I would recommend already existing parsers. See this answer as example.
If you truly want to be on your own you have to write simple state machine which will read data by individual columns. When reading column you have to take care about escaping rules. Only that way you could distinguish between line endings in data and line endings which separate rows

