Question about syntax
alaindebecker opened this issue · 1 comments
alaindebecker commented
Hi,
I coudn't reach python-etl@googlegroups.com, so I am posting a question here.
The standard way to write a petl job is in imperative style, by assigning variables :
table1 = etl.fromcsv('example.csv')
table2 = etl.convert(table1, 'foo', 'upper')
table3 = etl.convert(table2, 'bar', int)
table4 = etl.convert('baz', float)
table = etl.addfield(table4, 'quux', lambda row: row.bar * row.baz)
Of course it is possible to use a functional syntax :
table = etl.addfield(
etl.convert(
etl.convert(
etl.convert(
etl.fromcsv('example.csv'),
'foo', 'upper'),
'bar', int),
'baz', float),
'quux', lambda row: row.bar * row.baz)
My question is : is there a way to use a more natural chain syntax:
table = etl.fromcsv('example.csv') \
.convert('foo', 'upper') \
.convert('bar', int) \
.convert('baz', float) \
.addfield('quux', lambda row: row.bar * row.baz)
alaindebecker commented
Soorrryyyy, I should read the doc better.