uploading chapter 9 source code
This commit is contained in:
@@ -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='')
|
||||
Reference in New Issue
Block a user