Skip to content

gh-75008: guess lineterminator in csv.Sniffer - #18336

Closed
vmax wants to merge 5 commits into
python:mainfrom
vmax:bpo-30825
Closed

gh-75008: guess lineterminator in csv.Sniffer#18336
vmax wants to merge 5 commits into
python:mainfrom
vmax:bpo-30825

Conversation

@vmax

@vmaxvmax commented Feb 3, 2020

Copy link
Copy Markdown

@vmaxvmax changed the title Bpo 30825bpo-30825: guess lineterminator in csv.SnifferFeb 3, 2020
@vmax
vmax requested a review from csabellaFebruary 3, 2020 19:32
@csabella
csabella removed their request for review February 4, 2020 00:34
@vmaxvmaxmannequin mentioned this pull request Apr 10, 2022
Comment threadMisc/NEWS.d/next/Library/2018-02-12-05-10-28.bpo-30825.t0RXql.rst Outdated
Comment threadLib/csv.py Outdated

@rruuaanngrruuaanng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe csv.py should be sent to another reviewer for review.

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actionsgithub-actionsBot added the stale Stale PR or inactive for long period of time. label Apr 7, 2026
@serhiy-storchaka

Copy link
Copy Markdown
Member

Thank you for the patch, and sorry that it was left without attention for so long. The sniffer was rewritten on the main branch (gh-83273) and this patch no longer applies.

It should be easier now: the sample is split into lines keeping their line breaks, so detection can count '\r\n', '\n' and '\r' in a _detect_lineterminator() method, next to _detect_doublequote(). Note that falling back to os.linesep makes the result platform dependent; '\r\n' looks better for a sample without any line break.

@serhiy-storchakaserhiy-storchaka changed the title bpo-30825: guess lineterminator in csv.Sniffergh-75008: guess lineterminator in csv.SnifferJul 21, 2026
@github-actionsgithub-actionsBot removed the stale Stale PR or inactive for long period of time. label Jul 26, 2026
@serhiy-storchaka

Copy link
Copy Markdown
Member

#155061 implements this on the new engine. The only detail not covered above: the terminator is chosen by a majority vote among the line endings, with a tie broken in the order '\r\n', '\n', '\r'.

Closing as superseded. Thank you again for the patch.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@vmax@serhiy-storchaka@rruuaanng@the-knights-who-say-ni@ezio-melotti@bedevere-bot