1
2
3
4
5
6
7
8
9
10
11
|
#!/www/server/bin/php
<?php
# csv()
is(json_encode((new it_pipe(['data' => ["a\tb", "1\t2"]]))->csv()), '[{"a":"1","b":"2"}]');
is(json_encode((new it_pipe(['data' => ["a;b", "1;2"]]))->csv()), '[{"a":"1","b":"2"}]');
is(json_encode((new it_pipe(['data' => ["a,b", "1,2"]]))->csv()), '[{"a":"1","b":"2"}]');
is(json_encode((new it_pipe(['data' => ["\t", "1\t2"]]))->csv()), '[{"field0":"1","field1":"2"}]');
is(json_encode((new it_pipe(['data' => ["a\tb", "1\t2"]]))->csv("c,d")), '[{"c":"1","d":"2"}]');
is(json_encode((new it_pipe(['data' => ["a\tb", "1\t2"]]))->csv(['forceschema' => "c,d"])), '[{"c":"1","d":"2"}]');
is(json_encode((new it_pipe(['data' => ["a b\tb", "1\t2"]]))->csv(['fixcolnames' => true])), '[{"a_b":"1","b":"2"}]');
|