Class: Embulk::Guess::NewlineGuessPlugin
Instance Method Summary
collapse
#guess
from_java, #guess, new_java
Instance Method Details
#guess_text(config, sample_text) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/embulk/guess/newline.rb', line 7
def guess_text(config, sample_text)
cr_count = sample_text.count("\r")
lf_count = sample_text.count("\n")
crlf_count = sample_text.scan(/\r\n/).length
if crlf_count > cr_count / 2 && crlf_count > lf_count / 2
return {"parser" => {"newline" => "CRLF"}}
elsif cr_count > lf_count / 2
return {"parser" => {"newline" => "CR"}}
else
return {"parser" => {"newline" => "LF"}}
end
end
|