1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "csvText": `Customer ID, Full Name ,Email,Amount,Order Date
12C-001, Alice Smith ,ALICE@ACME.COM,1250.50,2026-08-01
13C-001,Alice Smith,alice@acme.com,1250.50,2026-08-01`,
14 "format": "auto",
15 "normalizeColumnNames": true,
16 "trimWhitespace": true,
17 "emptyAsNull": true,
18 "columnRules": [
19 {
20 "column": "amount",
21 "type": "number",
22 "required": true,
23 "min": 0
24 },
25 {
26 "column": "order_date",
27 "type": "date",
28 "required": true
29 },
30 {
31 "column": "email",
32 "type": "string",
33 "pattern": "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$"
34 }
35 ],
36 "deduplicateBy": [
37 "customer_id",
38 "order_date"
39 ],
40 "duplicateAction": "flag",
41 "caseInsensitiveDuplicates": true,
42 "maxRows": 20
43};
44
45
46const run = await client.actor("automation-lab/csv-excel-data-quality-cleaner").call(input);
47
48
49console.log('Results from dataset');
50console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
51const { items } = await client.dataset(run.defaultDatasetId).listItems();
52items.forEach((item) => {
53 console.dir(item);
54});
55
56