Skip to content

Commit 2c22f5e

Browse files
Merge pull request #2052 from gazon1/patch-1
Fixed bug when reading dataset with timestamp for sasrec model
2 parents aa5c4e1 + 7205f2a commit 2c22f5e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

recommenders/models/sasrec/util.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ def __init__(self, **kwargs):
3535
if self.filename:
3636
with open(self.filename, "r") as fr:
3737
sample = fr.readline()
38-
ncols = sample.strip().split(self.col_sep)
38+
ncols = len(sample.strip().split(self.col_sep))
3939
if ncols == 3:
4040
self.with_time = True
41-
else:
41+
elif ncols == 2:
4242
self.with_time = False
43+
else:
44+
raise ValueError(f"3 or 2 columns must be in dataset. Given {ncols} columns")
4345

4446
def split(self, **kwargs):
4547
self.filename = kwargs.get("filename", self.filename)

0 commit comments

Comments
 (0)