Read data from files

This commit is contained in:
Maciej Sobkowiak 2021-05-12 20:18:46 +02:00
parent 9ccc657af6
commit 7ea61e7e1f

View File

@ -1,18 +1,23 @@
import pandas as pd import pandas as pd
import numpy as np
import gzip import gzip
dev = pd.read_table('dev-0/in.tsv', error_bad_lines=False, header=None) dev = pd.read_table('dev-0/in.tsv', error_bad_lines=False, header=None)
test = pd.read_table('test-A/in.tsv', error_bad_lines=False, header=None) test = pd.read_table('test-A/in.tsv', error_bad_lines=False, header=None)
print(dev) X_train = []
y_train = []
train_y = []
train_X = []
with gzip.open('train/train.tsv.gz', 'r') as f: with gzip.open('train/train.tsv.gz', 'r') as f:
for l in f: for l in f:
line = l.decode('UTF-8').replace("\n", "").split("\t") line = l.decode('UTF-8').replace("\n", "").split("\t")
train_y.append(line[0]) y_train.append(line[0])
train_X.append(''.join(line[1:])) X_train.append(line[1:])
print(train_y[1:20]) X_train = np.asanyarray(X_train)
print(train_X[1:3]) y_train = np.asanyarray(y_train)
X_dev = dev[0].values
X_test = test[0].values
print(X_dev)