It looks like the py implementation just checks for several dialects: excel or excel_tab. So a simple implementation of something that just checks for ","or "\t":
COMMON_DELIMITERS = ['","',"\"\t\""]
def sniff(path)
first_line = File.open(path).first
return nil unless first_line
snif = {}
COMMON_DELIMITERS.each {|delim|snif[delim]=first_line.count(delim)}
snif = snif.sort {|a,b| b[1]<=>a[1]}
snif.size > 0 ? snif[0][0] : nil
end
: , , . ",", , snif[0][0] snif[0][0][1].
, count(delim), , , ( ) , --, ( ) , scan(delim).length.