forked from incubateind/idtcDay1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.php
34 lines (29 loc) · 1.02 KB
/
run.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once(dirname(__FILE__) . "/vendor/autoload.php");
$arguments = getopt("d::", array("data::"));
if (!isset($arguments["data"])) {
print "Data folder not set.";
exit(1);
}
$config = json_decode(file_get_contents($arguments["data"] . "/config.json"), true);
if (isset($config["storage"]["input"]["tables"][0]["destination"])) {
$sourceFile = $config["storage"]["input"]["tables"][0]["destination"];
} else {
$sourceFile = $config["storage"]["input"]["tables"][0]["source"];
}
$destinationFile = "sliced.csv";
try {
$splitter = new \Keboola\DockerDemo\Splitter();
$rows = $splitter->processFile(
$arguments["data"] . "/in/tables/{$sourceFile }",
$arguments["data"] . "/out/tables/{$destinationFile}",
$config["parameters"]["primary_key_column"],
$config["parameters"]["data_column"],
$config["parameters"]["string_length"]
);
} catch (\Keboola\DockerDemo\Splitter\Exception $e) {
print $e->getMessage();
exit(1);
}
print "Processed {$rows} rows.";
exit(0);