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
+14
View File
@@ -0,0 +1,14 @@
#pipeline3.py: Read data from a file and give results back to another file
import apache_beam as beam
from apache_beam.io import WriteToText, ReadFromText
with beam.Pipeline() as pipeline:
lines = pipeline | ReadFromText('sample1.txt')
subjects = (
lines
| 'Subjects' >> beam.FlatMap(str.split))
subjects | WriteToText(file_path_prefix='subjects',
file_name_suffix='.txt',
shard_name_template='')