Files
Python-for-Geeks/Chapter09/pipeline/pipeline2.py
T
2021-08-13 11:44:51 +05:30

18 lines
471 B
Python

#pipeline2.py: Separate subject with grade from a PCollection
import apache_beam as beam
def my_format(sub, marks):
yield '{}\t{}'.format(sub,marks)
with beam.Pipeline() as pipeline:
plants = (
pipeline
| 'Subjects' >> beam.Create([
('English','A'),
('Maths', 'B+'),
('Science', 'A-'),
('French', 'A'),
('Arts', 'A+'),
])
| 'Format subjects with marks' >> beam.FlatMapTuple(my_format)
| beam.Map(print))