-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread.py
28 lines (26 loc) · 913 Bytes
/
read.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
import numpy as np
# read the files line by line put into arrays
array1 = np.empty((70000, 3), dtype=object)
array2 = np.empty((70000, 3), dtype=object)
counter = 0
lineInFile = ""
ending = ">"
#try:
with open('dataset/sampleDB1.ttl', 'r') as file1:
for lineInFile in file1:
lineInFile = lineInFile.rstrip('\n').strip(" .").split("> ")
for n in range(0, 3, 1):
if lineInFile[n][0] == "<":
lineInFile[n] = lineInFile[n] + ending
array1[counter, n] = lineInFile[n]
counter += 1
counter = 0
with open('dataset/sampleDB2.ttl', 'r') as file2:
for lineInFile in file2:
lineInFile = lineInFile.rstrip('\n').strip(" .").split("> ")
for n in range(0, 3, 1):
if lineInFile[n][0] == "<":
lineInFile[n] = lineInFile[n] + ending
array2[counter, n] = lineInFile[n]
counter += 1
counter = 0