Created
September 27, 2012 13:37
-
-
Save ismaild/3794042 to your computer and use it in GitHub Desktop.
Producer for PyF
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
import os | |
import csv | |
f = os.path.join('/Users/ismail/sandbox/repos_own/pyf/','tmp.txt') | |
FIELDS = [ | |
'A', | |
'B', | |
'C', | |
'D' | |
] | |
csv.register_dialect('tuk', delimiter='|', quoting=csv.QUOTE_NONE) | |
reader = csv.DictReader(f, fieldnames=FIELDS, dialect='tuk') | |
class Rec(object): | |
def __init__(self, a, b, c, d): | |
self.a = a | |
self.b = b | |
self.c = c | |
self.d = d | |
def get_source(): | |
for row in reader: | |
print row | |
rec = Rec(row['a'],row['b'], | |
row['c'],row['d']) | |
yield rec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment