Skip to content

Instantly share code, notes, and snippets.

@ismaild
Created September 27, 2012 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismaild/3794042 to your computer and use it in GitHub Desktop.
Save ismaild/3794042 to your computer and use it in GitHub Desktop.
Producer for PyF
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