Skip to content

Commit 57e290d

Browse files
committed
Merge branch 'dev' of github.com:LibreCat/Catmandu into dev
2 parents 408c579 + 68a8d27 commit 57e290d

5 files changed

Lines changed: 65 additions & 5 deletions

File tree

Changes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Revision history for Catmandu
22

33
{{$NEXT}}
4+
- #403: Add support for BOM in CSV header ()
45

56
1.2024 2025-01-16 16:23:49 CET
67
- #402: Fix cli with Getopt::Long::Descriptive >= 0.116

README-Docker.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Catmandu Docker
2+
3+
For a quick installation of Catmandu using [Docker](https://www.docker.com) use the following command:
4+
5+
```
6+
docker run -it librecat/catmandu
7+
```
8+
9+
Now you should be able to run Catmandu in the Docker terminal:
10+
11+
```
12+
catmandu@d45e783d0bca:~$ catmandu help
13+
```
14+
15+
To have access to your local files use one of the following commands:
16+
17+
Windows:
18+
19+
```
20+
docker run -v C:\Users\yourname:/home/catmandu/Home -it librecat/catmandu
21+
```
22+
23+
OSX:
24+
25+
```
26+
docker run -v /Users/yourname:/home/catmandu/Home -it librecat/catmandu
27+
```
28+
29+
Linux:
30+
31+
```
32+
docker run -v /home/yourname:/home/catmandu/Home -it librecat/catmandu
33+
```
34+
35+
For more information about the Catmandu extension that are available in the Docker image check the [docker-catmandu](https://github.com/LibreCat/docker-catmandu) project.

lib/Catmandu.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ Stefan Weil
362362
363363
Tom Hukins
364364
365+
Michal Josef Špaček C<<michal.josef.spacek at gmail.com>>
366+
365367
=head1 QUESTIONS, ISSUES & BUG REPORTS
366368
367369
For any questions on the use of our modules, or bug reports, or feature requests,

lib/Catmandu/Importer/CSV.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ sub generator {
5858
state $csv = do {
5959
if ($self->header) {
6060
if ($self->fields) {
61-
$self->csv->getline($fh);
61+
$self->csv->header($fh, { 'sep_set' => [$self->sep_char] });
6262
$line++;
6363
}
6464
else {
65-
$self->_set_fields($self->csv->getline($fh));
65+
my @hdr = $self->csv->header($fh, { 'munge_column_names' => 'none', 'sep_set' => [$self->sep_char] });
66+
$self->_set_fields(\@hdr);
6667
$line++;
6768
}
6869
}

t/Catmandu-Importer-CSV.t

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,19 @@ my $importer = $pkg->new(file => \$csv);
2626

2727
isa_ok $importer, $pkg;
2828

29-
is_deeply $importer->to_array, $data;
29+
is_deeply $importer->to_array, $data, 'CSV with header.';
30+
31+
$csv = <<EOF;
32+
\xEF\xBB\xBF"name","age"
33+
"Patrick","39"
34+
"Nicolas","34"
35+
EOF
36+
37+
$importer = $pkg->new(file => \$csv);
38+
39+
isa_ok $importer, $pkg;
40+
41+
is_deeply $importer->to_array, $data, 'CSV with header, BOM.';
3042

3143
$data = [{0 => 'Patrick', 1 => '39'}, {0 => 'Nicolas', 1 => '34'},];
3244

@@ -37,7 +49,7 @@ EOF
3749

3850
$importer = $pkg->new(file => \$csv, header => 0);
3951

40-
is_deeply $importer->to_array, $data;
52+
is_deeply $importer->to_array, $data, 'CSV without header.';
4153

4254
$data = [{name => 'Nicolas', age => '34'},];
4355

@@ -48,7 +60,16 @@ EOF
4860

4961
$importer = $pkg->new(file => \$csv, sep_char => '\t');
5062

51-
is_deeply $importer->to_array, $data;
63+
is_deeply $importer->to_array, $data, 'CSV with header, separator is tab.';
64+
65+
$csv = <<EOF;
66+
\xEF\xBB\xBF"name" "age"
67+
"Nicolas" "34"
68+
EOF
69+
70+
$importer = $pkg->new(file => \$csv, sep_char => '\t');
71+
72+
is_deeply $importer->to_array, $data, 'CSV with header, separator is tab, BOM.';
5273

5374
done_testing;
5475

0 commit comments

Comments
 (0)