4
4
5
5
namespace Flow \ETL \Tests \Integration \DataFrame ;
6
6
7
- use function Flow \ETL \Adapter \CSV \from_csv ;
8
7
use function Flow \ETL \Adapter \Text \from_text ;
9
8
use function Flow \ETL \DSL \datetime_schema ;
10
9
use function Flow \ETL \DSL \df ;
11
10
use function Flow \ETL \DSL \float_schema ;
11
+ use function Flow \ETL \DSL \from_array ;
12
12
use function Flow \ETL \DSL \int_schema ;
13
13
use function Flow \ETL \DSL \schema ;
14
14
use function Flow \ETL \DSL \str_schema ;
@@ -19,11 +19,17 @@ final class AnalyzeTest extends IntegrationTestCase
19
19
public function test_analyzing_csv_file_with_auto_cast () : void
20
20
{
21
21
$ report = df ()
22
- ->read (from_csv (__DIR__ . '/Fixtures/Analyze/goldstock.csv ' ))
22
+ ->read (from_array ([
23
+ ['Index ' => 1 , 'Date ' => '2024-01-19 ' , 'Close ' => '2029.3 ' , 'Volume ' => '166078.0 ' , 'Open ' => '2027.4 ' , 'High ' => '2041.9 ' , 'Low ' => '2022.2 ' ],
24
+ ['Index ' => 2 , 'Date ' => '2024-01-20 ' , 'Close ' => '2029.3 ' , 'Volume ' => '166078.0 ' , 'Open ' => '2027.4 ' , 'High ' => '2041.9 ' , 'Low ' => '2022.2 ' ],
25
+ ['Index ' => 3 , 'Date ' => '2024-01-21 ' , 'Close ' => '2029.3 ' , 'Volume ' => '166078.0 ' , 'Open ' => '2027.4 ' , 'High ' => '2041.9 ' , 'Low ' => '2022.2 ' ],
26
+ ['Index ' => 4 , 'Date ' => '2024-01-22 ' , 'Close ' => '2029.3 ' , 'Volume ' => '166078.0 ' , 'Open ' => '2027.4 ' , 'High ' => '2041.9 ' , 'Low ' => '2022.2 ' ],
27
+ ['Index ' => 5 , 'Date ' => '2024-01-23 ' , 'Close ' => '2029.3 ' , 'Volume ' => '166078.0 ' , 'Open ' => '2027.4 ' , 'High ' => '2041.9 ' , 'Low ' => '2022.2 ' ],
28
+ ]))
23
29
->autoCast ()
24
30
->run (analyze: true );
25
31
26
- $ this ->assertSame (2511 , $ report ->statistics ()->totalRows ());
32
+ $ this ->assertSame (5 , $ report ->statistics ()->totalRows ());
27
33
$ this ->assertEquals (
28
34
schema (
29
35
int_schema ('Index ' ),
@@ -42,11 +48,17 @@ public function test_analyzing_csv_file_with_auto_cast() : void
42
48
public function test_analyzing_csv_file_with_limit () : void
43
49
{
44
50
$ report = df ()
45
- ->read (from_csv (__DIR__ . '/Fixtures/Analyze/goldstock.csv ' ))
46
- ->limit (100 )
51
+ ->read (from_array ([
52
+ ['Index ' => '1 ' , 'Date ' => '2024-01-19 ' , 'Close ' => '2029.3 ' , 'Volume ' => '166078.0 ' , 'Open ' => '2027.4 ' , 'High ' => '2041.9 ' , 'Low ' => '2022.2 ' ],
53
+ ['Index ' => '2 ' , 'Date ' => '2024-01-20 ' , 'Close ' => '2029.3 ' , 'Volume ' => '166078.0 ' , 'Open ' => '2027.4 ' , 'High ' => '2041.9 ' , 'Low ' => '2022.2 ' ],
54
+ ['Index ' => '3 ' , 'Date ' => '2024-01-21 ' , 'Close ' => '2029.3 ' , 'Volume ' => '166078.0 ' , 'Open ' => '2027.4 ' , 'High ' => '2041.9 ' , 'Low ' => '2022.2 ' ],
55
+ ['Index ' => '4 ' , 'Date ' => '2024-01-22 ' , 'Close ' => '2029.3 ' , 'Volume ' => '166078.0 ' , 'Open ' => '2027.4 ' , 'High ' => '2041.9 ' , 'Low ' => '2022.2 ' ],
56
+ ['Index ' => '5 ' , 'Date ' => '2024-01-23 ' , 'Close ' => '2029.3 ' , 'Volume ' => '166078.0 ' , 'Open ' => '2027.4 ' , 'High ' => '2041.9 ' , 'Low ' => '2022.2 ' ],
57
+ ]))
58
+ ->limit (2 )
47
59
->run (analyze: true );
48
60
49
- $ this ->assertSame (100 , $ report ->statistics ()->totalRows ());
61
+ $ this ->assertSame (2 , $ report ->statistics ()->totalRows ());
50
62
$ this ->assertEquals (
51
63
schema (
52
64
str_schema ('Index ' ),
0 commit comments