Skip to content

Commit

Permalink
fix file iter to convert int id to str
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatYYX committed Apr 19, 2017
1 parent 43ac6ff commit 3bd1769
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rltk/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,9 @@ def get_file_iterator(self, file_path, *args, **kwargs):
For `csv` file, `id_column` and `value_columns` (list) should be set. \
if there's no header, please set `field_names` (list).
Returns:
misc, list: id, value list.
str, list: id, value list. \
If the extracted id is a int, it will be convert to string with a 'int-' prefix,\
for json line only supports string as key in object.
"""
return FileIterator(file_path=self._get_abs_path(file_path), *args, **kwargs)

Expand Down
3 changes: 3 additions & 0 deletions rltk/file_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def next(self):
value = [line]

self._count += 1
# id should be a string
if isinstance(oid, int):
oid = 'int-' + str(oid)
return oid, value

except StopIteration as e:
Expand Down

0 comments on commit 3bd1769

Please sign in to comment.