1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "fileUrls": [
12 "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv"
13 ],
14 "rules": {
15 "expectedColumns": [
16 "sepal_length",
17 "sepal_width",
18 "petal_length",
19 "petal_width",
20 "species"
21 ],
22 "rowCountMin": 1,
23 "columns": {
24 "sepal_length": {
25 "type": "number",
26 "required": true,
27 "min": 0,
28 "max": 10
29 },
30 "sepal_width": {
31 "type": "number",
32 "required": true,
33 "min": 0,
34 "max": 10
35 },
36 "petal_length": {
37 "type": "number",
38 "required": true,
39 "min": 0,
40 "max": 10
41 },
42 "petal_width": {
43 "type": "number",
44 "required": true,
45 "min": 0,
46 "max": 2
47 },
48 "species": {
49 "required": true,
50 "enum": [
51 "setosa",
52 "versicolor",
53 "virginica"
54 ]
55 }
56 }
57 }
58};
59
60
61const run = await client.actor("ucchiii/csv-validator").call(input);
62
63
64console.log('Results from dataset');
65console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
66const { items } = await client.dataset(run.defaultDatasetId).listItems();
67items.forEach((item) => {
68 console.dir(item);
69});
70
71