Add a delimiters parameter to the csv.Sniffer constructor
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Feature or enhancement
csv.Sniffer.sniff() accepts an optional delimiters argument which restricts the set of characters that can be guessed as a delimiter. has_header() has no such argument, so the restriction cannot be applied to it.
I propose to add an optional delimiters parameter to the constructor, so that it applies to the sniffer rather than to a single call:
sniffer = csv.Sniffer(',;\t')
if sniffer.has_header(sample):
...
dialect = sniffer.sniff(sample)
It is used by both sniff() and has_header(). The delimiters argument of sniff(), if given, still takes precedence.
The given delimiters are also preferred in that order if several of them split the sample equally well: csv.Sniffer(';,') guesses ';' where csv.Sniffer(',;') guesses ','.
Linked PRs
- gh-155060
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dagli entry point csv.Sniffer, sniff() e has_header() descritti nell’issue, quindi esamina i test CSV esistenti per il loro comportamento attuale. Il lavoro è completato quando entrambi i metodi utilizzano la restrizione delimiters del costruttore, sniff() può sovrascriverla e i candidati a pari merito seguono l’ordine dei delimitatori fornito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- data
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 35/100