Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- multi read-csv($filename, $dict where { $dict }) {
- my @lines = $filename.IO.lines.list;
- my $hdr := split ',', @lines[0].cache;
- sub parse_row($row) {
- my $parts := split ',', $row;
- my %row_dict;
- for (zip $hdr, $parts) { %row_dict{$_[0]} = $_[1] };
- return %row_dict;
- }
- map &parse_row, @lines[1..*];
- }
- multi read-csv($filename, $dict where { !$dict }){
- map { split(',', $_) }, $filename.IO.lines
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement