colscan 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- colscan-0.2.0/LICENSE +202 -0
- colscan-0.2.0/PKG-INFO +278 -0
- colscan-0.2.0/README.md +253 -0
- colscan-0.2.0/pyproject.toml +57 -0
- colscan-0.2.0/setup.cfg +4 -0
- colscan-0.2.0/src/colscan/__init__.py +20 -0
- colscan-0.2.0/src/colscan/__main__.py +10 -0
- colscan-0.2.0/src/colscan/_engine/PROVENANCE.json +20 -0
- colscan-0.2.0/src/colscan/_engine/__init__.py +7 -0
- colscan-0.2.0/src/colscan/_engine/colname.py +276 -0
- colscan-0.2.0/src/colscan/_engine/taxonomy.py +157 -0
- colscan-0.2.0/src/colscan/_engine/validators.py +867 -0
- colscan-0.2.0/src/colscan/_engine/validators_it.py +578 -0
- colscan-0.2.0/src/colscan/cli.py +73 -0
- colscan-0.2.0/src/colscan/readers.py +296 -0
- colscan-0.2.0/src/colscan/reference.py +58 -0
- colscan-0.2.0/src/colscan/reference_data/SOURCES.md +66 -0
- colscan-0.2.0/src/colscan/reference_data/__init__.py +10 -0
- colscan-0.2.0/src/colscan/reference_data/icd10.txt +74721 -0
- colscan-0.2.0/src/colscan/reference_data/it_ateco.txt +4229 -0
- colscan-0.2.0/src/colscan/reference_data/it_ipa.json +146525 -0
- colscan-0.2.0/src/colscan/reference_data/it_territori.json +16187 -0
- colscan-0.2.0/src/colscan/report.py +149 -0
- colscan-0.2.0/src/colscan/scan.py +454 -0
- colscan-0.2.0/src/colscan.egg-info/PKG-INFO +278 -0
- colscan-0.2.0/src/colscan.egg-info/SOURCES.txt +37 -0
- colscan-0.2.0/src/colscan.egg-info/dependency_links.txt +1 -0
- colscan-0.2.0/src/colscan.egg-info/entry_points.txt +2 -0
- colscan-0.2.0/src/colscan.egg-info/requires.txt +6 -0
- colscan-0.2.0/src/colscan.egg-info/top_level.txt +1 -0
- colscan-0.2.0/tests/test_cli_and_report.py +104 -0
- colscan-0.2.0/tests/test_columns.py +97 -0
- colscan-0.2.0/tests/test_credit_card_chance.py +138 -0
- colscan-0.2.0/tests/test_db_readonly.py +90 -0
- colscan-0.2.0/tests/test_engine_provenance.py +85 -0
- colscan-0.2.0/tests/test_examples.py +79 -0
- colscan-0.2.0/tests/test_readers.py +120 -0
- colscan-0.2.0/tests/test_reference_lists.py +117 -0
- colscan-0.2.0/tests/test_validators_real_cases.py +89 -0
colscan-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
colscan-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: colscan
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Say what is inside each column of a table — semantic type and GDPR nature — with deterministic rules only. Runs offline.
|
|
5
|
+
Author: dbtool.it
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://dbtool.it
|
|
8
|
+
Keywords: gdpr,data-discovery,pii,column-classification,csv,parquet
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Legal Industry
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Topic :: Database
|
|
16
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Provides-Extra: parquet
|
|
21
|
+
Requires-Dist: pyarrow>=15.0; extra == "parquet"
|
|
22
|
+
Provides-Extra: db
|
|
23
|
+
Requires-Dist: SQLAlchemy>=2.0; extra == "db"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# colscan
|
|
27
|
+
|
|
28
|
+
**Tell what is inside each column of a table — its semantic type and its GDPR
|
|
29
|
+
nature — with deterministic rules only. Offline, no model, no account, no data
|
|
30
|
+
leaving your machine.**
|
|
31
|
+
|
|
32
|
+
```console
|
|
33
|
+
$ pip install colscan
|
|
34
|
+
$ colscan clienti.csv
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Why
|
|
38
|
+
|
|
39
|
+
Whoever has to keep a register of processing activities (art. 30 GDPR) has to know
|
|
40
|
+
that the column named `f_12` holds national identification numbers. In databases
|
|
41
|
+
that have been alive for fifteen years nobody knows: the columns are called
|
|
42
|
+
`desc`, `campo3`, `note`, the documentation lies, and the person who designed the
|
|
43
|
+
schema left in 2014.
|
|
44
|
+
|
|
45
|
+
The tools that solve this — Collibra, BigID, Atlan, Cyera — sell it inside
|
|
46
|
+
governance platforms priced on request, and they want to connect to your database
|
|
47
|
+
**from their cloud**. Google Cloud DLP charges per unit inspected: ten million
|
|
48
|
+
cells cost thousands. At the low end there is nothing.
|
|
49
|
+
|
|
50
|
+
colscan is the low end. It reads a sample of each column, applies rules that a
|
|
51
|
+
person can read and an auditor can check, and prints what it found.
|
|
52
|
+
|
|
53
|
+
## What it does, and what it refuses to do
|
|
54
|
+
|
|
55
|
+
A rule either **proves** something or it does not. colscan keeps three answers
|
|
56
|
+
apart and never blurs them:
|
|
57
|
+
|
|
58
|
+
| answer | meaning |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `personal` / `art.9` | a rule verified it — a mod-97 IBAN check, a codice fiscale check character, an exact match in an official list |
|
|
61
|
+
| `not personal` | same strength of evidence, and the type is not personal data |
|
|
62
|
+
| `not personal?` | a weak rule fired (any integer is a "sequential id"): an indication |
|
|
63
|
+
| `undetermined` | no rule can decide. Said plainly, with the reason |
|
|
64
|
+
| `empty` | the column is null or placeholder all the way down |
|
|
65
|
+
|
|
66
|
+
It does **not** guess to look useful. A column of surnames comes out
|
|
67
|
+
`undetermined`, because no regular expression can tell a surname from a city name
|
|
68
|
+
— many Italian surnames *are* place names. That answer is the honest one, and the
|
|
69
|
+
report says where the answer does exist (see the bottom of this page).
|
|
70
|
+
|
|
71
|
+
colscan is an analysis aid, **not a compliance certificate**. It reports evidence;
|
|
72
|
+
the legal qualification is the reader's.
|
|
73
|
+
|
|
74
|
+
## Example
|
|
75
|
+
|
|
76
|
+
```console
|
|
77
|
+
$ colscan examples/anagrafica.csv
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
colscan 0.2.0 · deterministic rules only · nothing leaves this machine
|
|
82
|
+
|
|
83
|
+
examples/anagrafica.csv · anagrafica.csv · csv, delimiter ';', encoding utf-8-sig
|
|
84
|
+
4 rows read, 4 sampled (seeded reservoir, reproducible)
|
|
85
|
+
|
|
86
|
+
COLUMN TYPE GDPR NULL UNREAD CONF SAMPLE
|
|
87
|
+
-------------------------------------------------------------------------
|
|
88
|
+
id sequential_id not personal? 0% 0% 0.30 1 | 2 | 3
|
|
89
|
+
codice_fiscale fiscal_code_it personal 25% 33% 1.00 RS…1U | RS…1R | VRDLGU85M15F205Z
|
|
90
|
+
iban iban personal 25% 33% 1.00 IT…56 | IT…56 | IT60XY542811101000000123456
|
|
91
|
+
email email personal 25% 0% 0.98 ma…om | l.…om | g.…om
|
|
92
|
+
note free_text personal 25% 100% name richiamare lunedì | sc…om | cliente storico
|
|
93
|
+
cognome person_surname undetermined 0% 75% name Rossi | Verdi | Esposito
|
|
94
|
+
importo_euro amount not personal? 0% 0% 0.50 1.234,50 | 89,00 | 12,00
|
|
95
|
+
sesso gender_label personal 0% 100% 0.90* M | F | M
|
|
96
|
+
cap postcode not personal 0% 0% 0.90* 20121 | 10121 | 80100
|
|
97
|
+
diagnosi icd_code art.9 25% 0% 0.85 … | … | …
|
|
98
|
+
vuota unknown empty 100% 0% 1.00
|
|
99
|
+
data date not personal? 0% 0% 0.85 12/05/2024 | 13/05/2024 | 14/05/2024
|
|
100
|
+
|
|
101
|
+
! note: email inside the text of 25% of the rows (1 cells, rule-verified)
|
|
102
|
+
? note: 100% of the non-null cells match no rule: no deterministic answer exists
|
|
103
|
+
? cognome: the column name is the only evidence
|
|
104
|
+
? cognome: 75% of the non-null cells match no rule: no deterministic answer exists
|
|
105
|
+
> cognome: POST /v1/split on dbtool.it resolves given name vs surname, any script
|
|
106
|
+
|
|
107
|
+
12 columns · 6 hold personal data with rule-level certainty (1 of them a special category, art. 9) · 1 undetermined
|
|
108
|
+
Sample values that a rule recognised as personal are masked; use --reveal to print them.
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Reading the report:
|
|
112
|
+
|
|
113
|
+
* `!` a rule verified something inside the column — including one row in a
|
|
114
|
+
thousand. A mod-97 that passes is not noise, so there is no frequency threshold
|
|
115
|
+
to tune: a single confirmed e-mail address inside a `note` column puts that
|
|
116
|
+
column in the register.
|
|
117
|
+
* `?` something a person has to check, with the reason.
|
|
118
|
+
* `~` the rules also saw other types, with their share.
|
|
119
|
+
* `>` a column whose type is decidable, but not by a rule.
|
|
120
|
+
* `UNREAD` is the share of non-null cells that matched no rule. It is kept apart
|
|
121
|
+
from `NULL` on purpose: a column of free text is not an empty column, and an
|
|
122
|
+
empty column is not an unreadable one.
|
|
123
|
+
|
|
124
|
+
Sample values recognised as personal are masked (`RS…1U`) so the report can be
|
|
125
|
+
pasted into a ticket. `--reveal` prints them in full.
|
|
126
|
+
|
|
127
|
+
## Usage
|
|
128
|
+
|
|
129
|
+
```console
|
|
130
|
+
colscan clienti.csv # CSV/TSV: separator and encoding sniffed
|
|
131
|
+
colscan clienti.csv --delimiter ';' # or told
|
|
132
|
+
colscan export.parquet # needs: pip install "colscan[parquet]"
|
|
133
|
+
colscan warehouse.sqlite --table clienti # SQLite: no extra needed
|
|
134
|
+
colscan postgresql://user:pw@host/db --schema public # needs: pip install "colscan[db]"
|
|
135
|
+
colscan clienti.csv --json # machine-readable, same content
|
|
136
|
+
colscan clienti.csv --rows 100000 # sample size per column (default 10000)
|
|
137
|
+
colscan clienti.csv --fail-on-personal # exit 1 when personal data is certain
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`python -m colscan …` works too, for a machine where `pip install --user` puts the
|
|
141
|
+
console script somewhere that is not in `PATH`.
|
|
142
|
+
|
|
143
|
+
Sampling is a seeded reservoir over the whole table, not the first N rows: real
|
|
144
|
+
exports are sorted, and the head of a sorted file is not the file. Same `--seed`,
|
|
145
|
+
same report — a report nobody can reproduce is not evidence.
|
|
146
|
+
|
|
147
|
+
Two worked examples, with their reports committed next to them (and a test that
|
|
148
|
+
keeps them true): [`examples/`](examples/README.md).
|
|
149
|
+
|
|
150
|
+
### Python
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from colscan import scan_column
|
|
154
|
+
|
|
155
|
+
result = scan_column(["RSSMRA80A01H501U", "VRDLGU85M15F205Z"], name="cf")
|
|
156
|
+
result["type"] # 'fiscal_code_it'
|
|
157
|
+
result["gdpr"]["personal"] # True
|
|
158
|
+
result["gdpr"]["basis"] # 'rule'
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
As a library the bundled reference lists load on demand — one call, then ICD-10
|
|
162
|
+
and the Italian registers decide there too:
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from colscan import reference, scan_column
|
|
166
|
+
|
|
167
|
+
reference.load() # the bundled official lists
|
|
168
|
+
icd = scan_column(["C50", "J45", "E11"], name="diagnosi")
|
|
169
|
+
icd["type"] # 'icd_code'
|
|
170
|
+
icd["gdpr"]["special_category"] # True — art. 9, exact match in ICD-10-CM
|
|
171
|
+
icd["gdpr"]["basis"] # 'rule'
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## What it recognises
|
|
175
|
+
|
|
176
|
+
* **Check digits — certainty.** IBAN (mod-97), Italian codice fiscale (including
|
|
177
|
+
omocodia variants), Italian VAT numbers. Payment cards are the one exception
|
|
178
|
+
worth reading below, because one check digit is not the same evidence as a
|
|
179
|
+
mod-97.
|
|
180
|
+
* **Unmistakable shapes.** E-mail, URL, UUID, IPv4/IPv6, MAC, hex digests,
|
|
181
|
+
ISO 8601 date and datetime, ISO periods (`2026-W33`, `2026Q3`), opening hours,
|
|
182
|
+
coordinates, international phone numbers, file paths, domains.
|
|
183
|
+
* **Closed vocabularies.** ISO 3166 country codes, ISO 4217 currencies,
|
|
184
|
+
continents, booleans, sex labels, administrative regions.
|
|
185
|
+
* **Italian identifiers nobody else implements.** CIG and CUP (structure only,
|
|
186
|
+
because neither publishes a verifiable check digit — the reasoning is in the
|
|
187
|
+
source), and, against the official registers bundled in the package, Belfiore
|
|
188
|
+
cadastral codes, ISTAT municipality codes, NUTS, school codes, IPA and
|
|
189
|
+
e-invoicing office codes, ATECO.
|
|
190
|
+
* **Personal data buried in free text.** A `note` column with one e-mail address,
|
|
191
|
+
IBAN, codice fiscale or phone number per thousand rows is reported as a column
|
|
192
|
+
that *contains* personal data — while staying a column of notes.
|
|
193
|
+
|
|
194
|
+
### Payment cards, and why they get treated differently
|
|
195
|
+
|
|
196
|
+
A card number carries **one** check digit (Luhn), so about one card-shaped digit
|
|
197
|
+
sequence in ten satisfies it by luck — against roughly one in thousands for an
|
|
198
|
+
IBAN mod-97. Two consequences, both deliberate:
|
|
199
|
+
|
|
200
|
+
* A number is only called a card if it also has an **issued prefix** (IIN) with a
|
|
201
|
+
length that issuer actually uses, per ISO/IEC 7812. Measured on 5.000 random
|
|
202
|
+
16-digit sequences: 9,6% pass Luhn, 2,6% pass Luhn *and* the prefix. The price is
|
|
203
|
+
declared — closed-loop cards (loyalty, meal vouchers) and Maestro numbers outside
|
|
204
|
+
the published IIN list are no longer recognised.
|
|
205
|
+
* A **minority** of such cells inside a column of numeric codes is reported, but
|
|
206
|
+
**not** as certainty, and the report says why: «3 of the 60 cells that have the
|
|
207
|
+
shape and prefix of a card also pass its single check digit, which chance alone
|
|
208
|
+
does 10% of the time». A column of order numbers is not a column of payment
|
|
209
|
+
cards, and an earlier version of this tool said it was.
|
|
210
|
+
|
|
211
|
+
A column that is *made of* cards, or a card found inside a sentence in a free-text
|
|
212
|
+
column, is still reported as certainty — that is the finding this tool exists for.
|
|
213
|
+
|
|
214
|
+
### Reference lists: bundled, official, replaceable
|
|
215
|
+
|
|
216
|
+
Health data and Italian register-backed identifiers are decided against four
|
|
217
|
+
official lists, **bundled in the package** — a fresh install reports a `diagnosi`
|
|
218
|
+
column as `icd_code`, art. 9, with no flag and nothing to download:
|
|
219
|
+
|
|
220
|
+
| list | contents | source | licence |
|
|
221
|
+
|---|---|---|---|
|
|
222
|
+
| `icd10.txt` | 74,721 ICD-10-CM FY2026 codes | CDC / NCHS | public domain (US Gov) |
|
|
223
|
+
| `it_territori.json` | 7,896 municipalities: Belfiore cadastral, ISTAT, NUTS | ISTAT | CC BY 4.0 |
|
|
224
|
+
| `it_ipa.json` | 23,744 IPA + 122,775 e-invoicing office codes | AGID / IndicePA | CC BY 4.0 |
|
|
225
|
+
| `it_ateco.txt` | 4,229 ATECO codes (2025 + 2022) | ISTAT | CC BY 4.0 |
|
|
226
|
+
|
|
227
|
+
Provenance, retrieval date and SHA-256 of every list: `colscan/reference_data/SOURCES.md`
|
|
228
|
+
(regenerate with `scripts/fetch_it_codes.py` in the dbtool-platform repo). A test
|
|
229
|
+
pins each file to its recorded hash: a list a rule decides with is not documentation.
|
|
230
|
+
|
|
231
|
+
No model weights and no training data ship, ever — the lists are the only data in
|
|
232
|
+
the package. If you keep the registers updated yourself, your copies win:
|
|
233
|
+
|
|
234
|
+
```console
|
|
235
|
+
colscan clienti.csv --reference-dir ~/reference # or COLSCAN_REFERENCE_DIR
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Expected file names, all optional: `icd10.txt`, `it_territori.json`,
|
|
239
|
+
`it_ipa.json`, `it_ateco.txt`. A missing file puts that rule back to abstaining —
|
|
240
|
+
see `colscan/reference.py` for the JSON keys.
|
|
241
|
+
|
|
242
|
+
## Databases: read-only, and checked
|
|
243
|
+
|
|
244
|
+
The tool issues nothing but `SELECT`. On top of that it asks the server to make the
|
|
245
|
+
session read-only and **verifies the answer** before reading any table — if the
|
|
246
|
+
server does not confirm it, colscan stops instead of scanning. SQLite files are
|
|
247
|
+
opened `mode=ro`, which also stops a mistyped path from creating an empty database.
|
|
248
|
+
Each table says which of the two happened in its header line, and a dialect with no
|
|
249
|
+
known read-only switch is scanned with that stated plainly rather than implied.
|
|
250
|
+
|
|
251
|
+
Point it at an account with `SELECT` privileges only anyway: two locks are better
|
|
252
|
+
than one, and the second one is the only one your DBA can see.
|
|
253
|
+
|
|
254
|
+
## Privacy
|
|
255
|
+
|
|
256
|
+
colscan makes no network connection. Cell values are never written anywhere: they
|
|
257
|
+
are read, counted and dropped. The report contains types, fractions and masked
|
|
258
|
+
samples. There is no telemetry and there is no account.
|
|
259
|
+
|
|
260
|
+
## Requirements
|
|
261
|
+
|
|
262
|
+
Python 3.10+. No dependencies. `pyarrow` only for Parquet, `SQLAlchemy` only for
|
|
263
|
+
databases other than SQLite.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
A rule proves what has a verifiable form. It cannot decide whether a name is a
|
|
268
|
+
given name or a surname, what gender a first name suggests, or which institution
|
|
269
|
+
an affiliation string refers to — no regular expression can. **dbtool.it** serves
|
|
270
|
+
exactly those:
|
|
271
|
+
|
|
272
|
+
| endpoint | what it resolves |
|
|
273
|
+
|---|---|
|
|
274
|
+
| `POST /v1/gender` | gender (and likely nationality) from a first name |
|
|
275
|
+
| `POST /v1/split` | given name vs surname, any script |
|
|
276
|
+
| `POST /v1/affiliation` | affiliation -> country, plus ROR institution linking |
|
|
277
|
+
|
|
278
|
+
Free plan, no data stored: <https://dbtool.it>
|