diff --git a/pgloader/fixedreader.py b/pgloader/fixedreader.py index f351b07..8356682 100644 --- a/pgloader/fixedreader.py +++ b/pgloader/fixedreader.py @@ -65,10 +65,34 @@ class FixedReader(DataReader): start = self.start, end = self.end) + # don't forget COUNT and FROM_COUNT option + nb_lines = 0 + begin_linenb = None + + ## + # if -F was not used, we can state that begin = 0 + # + # warning: FROM_ID is ignored + if FROM_COUNT == 0: + self.log.debug('beginning on first line') + begin_linenb = 1 + for line in self.fd: - line = line.strip("\n") - llen = len(line) - columns = [] + line = line.strip("\n") + llen = len(line) + columns = [] + offsets = [self.fd.line_nb] + nb_lines += 1 + + ## + # if -F is used, count lines to skip, and skip them + if FROM_COUNT > 0: + if nb_lines < FROM_COUNT: + continue + + if nb_lines == FROM_COUNT: + begin_linenb = nb_lines + self.log.info('reached beginning on line %d', nb_lines) for cname, cpos in self.columns: start, length = self.positions[cname]