uploading chapter 9 source code

This commit is contained in:
muassif
2021-06-15 23:10:30 +04:00
committed by GitHub
parent ac10d74a74
commit 360b7f1420
10 changed files with 259 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
#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))