1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "rows": [
12 {
13 "company": "Blue Door Bakery",
14 "contact": "MARIA KHOURY",
15 "phone": "03 123 456",
16 "email": "Maria@BlueDoor.lb",
17 "website": "www.bluedoor.lb/",
18 "country": "lebanon",
19 "added": "03/04/2024"
20 },
21 {
22 "company": "Blue Door Bakery",
23 "contact": "Khoury, Maria",
24 "phone": "+961 3 123 456",
25 "email": "maria@bluedoor.lb",
26 "website": "https://bluedoor.lb",
27 "country": "LB",
28 "added": "2024-04-03"
29 },
30 {
31 "company": "Cedar & Sons Ltd",
32 "contact": "john smith jr",
33 "phone": "+1 512 677 7667",
34 "email": "orders@cedarsons.com",
35 "website": "HTTP://CedarSons.com/?utm_source=newsletter",
36 "country": "United States",
37 "added": "March 5, 2024"
38 },
39 {
40 "company": "CEDAR & SONS",
41 "contact": "",
42 "phone": "+1 (512) 677-7667",
43 "email": "",
44 "website": "cedarsons.com",
45 "country": "USA",
46 "added": ""
47 },
48 {
49 "company": "Atlas Plumbing",
50 "contact": "Dr. Rami Haddad",
51 "phone": "71 555 888",
52 "email": "",
53 "website": "atlasplumbing.com.lb",
54 "country": "Lebanon",
55 "added": "12 Jan 2024"
56 },
57 {
58 "company": "Atlas Plumbing SARL",
59 "contact": "",
60 "phone": "71555888",
61 "email": "info@atlasplumbing.com.lb",
62 "website": "",
63 "country": "LB",
64 "added": "N/A"
65 },
66 {
67 "company": "Nile Dental Clinic",
68 "contact": "Dr. Amira Hassan",
69 "phone": "+20 100 123 4567",
70 "email": "contact@niledental.eg",
71 "website": "niledental.eg",
72 "country": "Egypt",
73 "added": "2024-01-12"
74 },
75 {
76 "company": "Berlin Bike Shop GmbH",
77 "contact": "Anna MÜLLER",
78 "phone": "+49 30 901820",
79 "email": "N/A",
80 "website": "https://www.berlinbike.de/shop",
81 "country": "Germany",
82 "added": "2024-02-29"
83 },
84 {
85 "company": "berlin bike shop",
86 "contact": "",
87 "phone": "+49 30 901820",
88 "email": "info@berlinbike.de",
89 "website": "berlinbike.de",
90 "country": "DE",
91 "added": ""
92 },
93 {
94 "company": "Cafe Beirut",
95 "contact": "",
96 "phone": "not a number",
97 "email": "hello@cafebeirut",
98 "website": "cafebeirut.com",
99 "country": "Lebanon",
100 "added": "n/a"
101 },
102 {
103 "company": "Sunrise Yoga",
104 "contact": "Priya Patel",
105 "phone": "+91 98765 43210",
106 "email": "priya@sunriseyoga.in",
107 "website": "sunriseyoga.in/",
108 "country": "india",
109 "added": "05/03/2024"
110 },
111 {
112 "company": "",
113 "contact": "",
114 "phone": "",
115 "email": "",
116 "website": "",
117 "country": "",
118 "added": ""
119 },
120 {
121 "company": "Sunrise Yoga Studio",
122 "contact": "PRIYA PATEL",
123 "phone": "",
124 "email": "PRIYA@sunriseyoga.in",
125 "website": "www.sunriseyoga.in",
126 "country": "IN",
127 "added": ""
128 }
129 ],
130 "rules": [
131 "*: trim",
132 "company: title",
133 "contact: split-name",
134 "phone: phone country=LB",
135 "email: email",
136 "website: domain into=domain",
137 "website: url",
138 "country: country",
139 "added: date"
140 ],
141 "defaultCountry": "LB",
142 "dedupeBy": [
143 "phone",
144 "email"
145 ],
146 "dedupeMatch": "any",
147 "keep": "most-complete",
148 "dropEmptyColumns": true,
149 "renameFields": {
150 "company": "businessName"
151 },
152 "exportCsv": true
153};
154
155
156const run = await client.actor("opstoolkit/dataset-cleaner").call(input);
157
158
159console.log('Results from dataset');
160console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
161const { items } = await client.dataset(run.defaultDatasetId).listItems();
162items.forEach((item) => {
163 console.dir(item);
164});
165
166