title: How to read and parse data from PubSub topic into a beam pipeline and print it
body: <p>I have a program which creates a topic in pubSub and also publishes messages to the topic. I also have an automated dataflow job(using a template) which saves these messages into my BigQuery table. Now I intend to replace the template based job with a python pipeline where my requirement is to read data from PubSub, apply transformations and save the data into BigQuery/publish to another PubSub topic. I started writing the script in python and did a lot of trial and error to achieve it but to my dismay, I could not achieve it. The code looks like this:</p>
  
  <pre><code>import apache_beam as beam
  from apache_beam.io import WriteToText
  TOPIC_PATH = "projects/test-pipeline-253103/topics/test-pipeline-topic"
  OUTPUT_PATH = "projects/test-pipeline-253103/topics/topic-repub"
  
  def run():
      o = beam.options.pipeline_options.PipelineOptions()
      p = beam.Pipeline(options=o)
  
      print("I reached here")
      # # Read from PubSub into a PCollection.
      data = (
          p
          | "Read From Pub/Sub" &gt;&gt; beam.io.ReadFromPubSub(topic=TOPIC_PATH)
      )
      data | beam.io.WriteToPubSub(topic=OUTPUT_PATH)
      print("Lines: ", data)
  run()
  </code></pre>
  
  <p>I will really appreciate if I can get some help at the earliest.
  Note: I have my project set up on google cloud and I have my script running locally. </p>