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