diff --git a/iofmt/text_input.py b/iofmt/text_input.py index 05929ed..5f3efd4 100644 --- a/iofmt/text_input.py +++ b/iofmt/text_input.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# $Id: text_input.py,v 1.5 2011-09-05 19:09:21 wirawan Exp $ +# $Id: text_input.py,v 1.6 2011-09-16 21:21:23 wirawan Exp $ # # wpylib.iofmt.text_input module # Quick-n-dirty text input utilities @@ -82,19 +82,21 @@ class text_input(object): def next_rec(self): '''Yields the next record, which is already separated into fields.''' + comment_char = getattr(self, "comment_char", "#") while True: self.lineno += 1 L = self.file.next() - F = self.field_filtering_proc(L.split("#")[0].split()) + F = self.field_filtering_proc(L.split(comment_char)[0].split()) if len(F) > 0 or not self.skip_blank_lines: return F def next_line(self): '''Yields the next line, which is already separated into fields.''' + comment_char = getattr(self, "comment_char", "#") while True: self.lineno += 1 L = self.file.next() - F = self.field_filtering_proc(L.split("#")[0].rstrip()) + F = self.field_filtering_proc(L.split(comment_char)[0].rstrip()) if len(F) > 0 or not self.skip_blank_lines: return F