Skip to content

v0.48.0

Choose a tag to compare

@github-actions github-actions released this 02 Dec 00:25
· 26 commits to master since this release
1a8cbb5

Highlights

One method for csv cells. ->cells() reads every row, one row, one column, or one cell:

$prices->cells()                          // every row
$prices->cells(row: 0)                    // the first row (-1 is the last)
$prices->cells(column: 'price')           // [3, 5]
$prices->cells(row: 1, column: 'price')   // 5

Puzzle input just works. A ```csv block of space-separated numbers splits into numbers, rows can have different lengths, and a first line of numbers is data, not a header:

echo $numbers->cells(row: 0)          // [-903, -642, -518, -585, 446]
echo $numbers->cells(row: -1)->sum()  // 1545

Cells written as numbers come out as numbers (codes such as 007 stay text). Tabs and semicolons split cells too, when there are no commas.

->numbers() on lists. Numbers stay, text gives the numbers in it, and inner lists are read: ['-3 4', 5]->numbers() is [-3, 4, 5].

Flags written as flags. header: false now gets a KS6024 style warning with a fix that writes not header (and overwrite: true becomes overwrite).

Behaviour changes

  • A csv's ->rows() and ->column() are retired in favour of ->cells(). Each is an error that names the replacement, and the quick fix keeps the arguments (->column('price') becomes ->cells(column: 'price')). See docs/upgrading.md.
  • csv cells written as numbers are now numbers, not text.
  • When a script doesn't say header or not header, a csv's first line is a header unless every cell on it is a number. .headers is empty for such a csv.
  • KS6024 (style warning): a yes/no option given true or false by name.

What's Changed

  • Read csv cells with one ->cells(row:, column:), and split numbers by spaces by @kylepantall in #345

Full Changelog: v0.47.0...v0.48.0