| 1 |
nino.borges |
938 |
"""
|
| 2 |
|
|
|
| 3 |
|
|
ConcordanceDatToDictionary
|
| 4 |
|
|
|
| 5 |
|
|
Created by:
|
| 6 |
|
|
Emanuel Borges
|
| 7 |
|
|
09.03.2025
|
| 8 |
|
|
|
| 9 |
|
|
This program will take a DAT export from Relativity and will return a dictionary where the column names are the keys.
|
| 10 |
|
|
|
| 11 |
|
|
"""
|
| 12 |
|
|
|
| 13 |
|
|
import csv
|
| 14 |
|
|
|
| 15 |
|
|
|
| 16 |
|
|
class ConcordanceLoader:
|
| 17 |
|
|
def __init__(self, filePath):
|
| 18 |
|
|
self.filePath = filePath
|
| 19 |
|
|
self.delimiter = '\x14' # ASCII 20
|
| 20 |
|
|
self.quotechar = '\xfe' # ASCII 254
|
| 21 |
|
|
self.records = []
|
| 22 |
|
|
|
| 23 |
|
|
|
| 24 |
|
|
def load(self):
|
| 25 |
|
|
with open(self.filePath, 'r', encoding='utf-8', newline='') as file:
|
| 26 |
|
|
reader = csv.reader(file, delimiter = self.delimiter, quotechar = self.quotechar)
|
| 27 |
|
|
self.records = [row for row in reader]
|
| 28 |
|
|
|
| 29 |
|
|
|
| 30 |
|
|
def get_headers(self):
|
| 31 |
|
|
return self.records[0] if self.records else []
|
| 32 |
|
|
|
| 33 |
|
|
def get_data(self):
|
| 34 |
|
|
return self.records[1:] if len(self.records) >1 else []
|
| 35 |
|
|
|
| 36 |
|
|
def get_all(self):
|
| 37 |
|
|
return self.records
|
| 38 |
|
|
|
| 39 |
|
|
|
| 40 |
|
|
|
| 41 |
|
|
|
| 42 |
|
|
|
| 43 |
|
|
|
| 44 |
|
|
|
| 45 |
|
|
|