-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.py
60 lines (29 loc) · 1.33 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from piianalyzer.analyzer import PiiAnalyzer
import logging
import numpy as np
import pandas as p
pii_details = {
'N': 'name',
'P': 'phone_no',
'A': 'address',
'C': 'credit_card_no',
'E': 'email_address',
'O': 'organization'
}
# This function will return the results of a csv file to find personally identifable info(PII)
def return_report(csv):
piianalyzer = PiiAnalyzer(csv) # Feeding in csv file to PIIAnalyzer...
dataset = set() # set dataset object to set method
analysis = piianalyzer.analysis() # Assigning the results of the analysis to analysis var...
np.vectorize(lambda cell: dataset.update({analysis(a)for a in cell}))
return {
'check_pii_detail:pii-found': ('PII details found...', logging.INFO, [pii_details[d[0]] for d in dataset])
}
# This function will return the workflow taken from return_report, feeds a csv file into return_report
def get_workflow(filename):
workflow = { # Setting up workflow dict...
'loading': (p.read_csv, filename), # Using Pandas library to read csv file passed in, and also pass the filename
'report_returned': (return_report, 'loading'), # Using return_report and loading csv file....
'output': (list, ['report_returned']) # This will be the output
}
return workflow # Returns workflow dict