-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_loader.py
41 lines (37 loc) · 1.09 KB
/
data_loader.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
import csv
import pandas as pd
def fetch_data(path):
data = []
with open(path) as csv_file:
csv_file.readline()
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
sentence = ' '.join(row[1:7])
data.append((sentence, int(row[7])-1))
return data
def fetch_data2(path, start=1):
data = []
with open(path) as csv_file:
csv_file.readline()
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
sentence = row[start:7]
data.append((sentence, int(row[7])-1))
return data
def fetch_test(path):
data = []
with open(path) as csv_file:
csv_file.readline()
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
sentence = row[4:7]
data.append(sentence)
return data
def get_id(path):
ids = []
with open(path) as csv_file:
csv_file.readline()
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
ids.append(row[0])
return ids