Last active
May 5, 2017 23:50
-
-
Save ivarg/e9c5d8744d2394f0d92161fa13aaf654 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CsvFileSource(beam.io.filebasedsource.FileBasedSource): | |
def read_records(self, file_name, range_tracker): | |
[...] | |
reader = csv.reader(_File2Iterator(self._file), delimiter=self.delimiter) | |
[...] | |
class _File2Iterator(object): | |
def __init__(self, obj): | |
self._obj = obj | |
def __iter__(self): | |
return self | |
def next(self): | |
line = self._obj.readline() | |
if line == None or line == '': | |
raise StopIteration | |
return line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment