Module: WebStruct::Page::CsvHeaderSniffer
- Defined in:
- lib/webstruct/page/csv_header_sniffer.rb
Overview
Heuristic for whether the first row of a CSV/TSV body is a header row. Conservative: returns false when uncertain. See README.
Constant Summary collapse
- NUMERIC =
A numeric cell is a string that matches this regex.
/\A-?\d+(?:\.\d+)?\z/
Class Method Summary collapse
-
.first_row_headers?(body, separator = ",") ⇒ Boolean
Returns true when the first row of a CSV/TSV body is a header row.
Class Method Details
.first_row_headers?(body, separator = ",") ⇒ Boolean
Returns true when the first row of a CSV/TSV body is a header row.
Conservative: returns false when uncertain. See README.
23 24 25 26 27 28 29 |
# File 'lib/webstruct/page/csv_header_sniffer.rb', line 23 def first_row_headers?(body, separator = ",") rows = first_two_rows(body, separator) return false if rows.size < 2 header_like_first_row?(rows[0], rows[1]) end |