|
5 | 5 |
|
6 | 6 | parser = argparse.ArgumentParser() |
7 | 7 | parser.add_argument('-f', '--fileName', help='the CSV file of headings. optional - if not provided, the script will ask for input') |
8 | | -parser.add_argument('-t', '--threshold', help='the threshold (e.g. \'90\' means the strings are 90% similar and 10% different ). optional - if not provided, the script will ask for input') |
| 8 | +parser.add_argument('-c', '--columnName', help='the name of the column in the CSV file containing the strings to be compared. optional - if not provided, the script will ask for input') |
| 9 | +parser.add_argument('-t', '--threshold', help='the threshold (e.g. \'90\' means the strings are 90% similar and 10% different). optional - if not provided, the script will ask for input') |
9 | 10 | args = parser.parse_args() |
10 | 11 |
|
11 | 12 | if args.fileName: |
12 | 13 | fileName = args.fileName |
13 | 14 | else: |
14 | 15 | fileName = raw_input('Enter the file name of the CSV of headings (including \'.csv\'): ') |
| 16 | +if args.columnName: |
| 17 | + columnName = args.columnName |
| 18 | +else: |
| 19 | + columnName = raw_input('Enter the name of the column in the CSV file containing the strings to be compared: ') |
15 | 20 | if args.threshold: |
16 | 21 | threshold = int(args.threshold) |
17 | 22 | else: |
18 | | - threshold = int(raw_input('Enter threshold (e.g. \'90\' means the strings are 90% similar and 10% different ): ')) |
| 23 | + threshold = int(raw_input('Enter threshold (e.g. \'90\' means the strings are 90% similar and 10% different): ')) |
19 | 24 |
|
20 | 25 | startTime = time.time() |
21 | 26 | nameList = [] |
22 | 27 | with open(fileName) as csvfile: |
23 | 28 | reader = csv.DictReader(csvfile) |
24 | 29 | for row in reader: |
25 | | - nameList.append(str(row['prefLabel'])) |
| 30 | + nameList.append(str(row[columnName])) |
26 | 31 | counter = len(nameList) |
27 | 32 | f=csv.writer(open(fileName[:fileName.index('.')]+'NearMatches.csv','wb')) |
28 | 33 | f.writerow(['percentage']+['name1']+['name2']) |
|
0 commit comments