Pandas assumptions separator with sep = None

Pandas documentation has the following:

With sep = None, read_csv will try to draw the separator output automatically in some cases by "sniffing".

How can I access pandas' for a delimiter?

I want to read in 10 lines of my file, pandas guess the separator and run my GUI with the separator already selected. But I don’t know how to access what pandas considers a delimiter.

Also, is there a way to pass pandas a list of strings to limit his guesses?

+4
source share
2 answers

, , read_csv. pandas Sniffer csv. , :

import csv
s = csv.Sniffer()
print s.sniff("a,b,c").delimiter
print s.sniff("a;b;c").delimiter
print s.sniff("a#b#c").delimiter

:

,
;
#

, Sniffer.sniff(), .

+6

csv.Sniffer - , , . , , :

reader = pd.read_csv('path/to/file.tar.gz', sep=None, engine='python', iterator=True)
sep = reader._engine.data.dialect.delimiter
reader.close()
0

All Articles