Merge branch 'Branch_Karen' of https://gogs.gtsplab.com:5432/j/python-bootcamp into Branch_Karen

This commit is contained in:
2023-05-05 15:04:40 -04:00
2 changed files with 11 additions and 10 deletions
+6 -6
View File
@@ -3,8 +3,9 @@ import csv
import os import os
import asyncio import asyncio
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "C:/Users/Karen/AppData/Roaming/gcloud/application_default_credentials.json" # os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "C:/Users/Karen/AppData/Roaming/gcloud/application_default_credentials.json"
project_id = "fp-20230425" # project_id = "fp-20230425"
project_id = "svig-384801"
''' '''
topic_name = "fp-topic-NFL-zipcodes" topic_name = "fp-topic-NFL-zipcodes"
@@ -28,8 +29,6 @@ publisher = pubsub_v1.PublisherClient()
topic_name = "fp-topic-NFL-zipcodes" topic_name = "fp-topic-NFL-zipcodes"
topic_path = publisher.topic_path(project_id, topic_name) topic_path = publisher.topic_path(project_id, topic_name)
# Create a Pub/Sub subscription # Create a Pub/Sub subscription
subscriber = pubsub_v1.SubscriberClient() subscriber = pubsub_v1.SubscriberClient()
''' '''
@@ -41,7 +40,8 @@ subscription = subscriber.create_subscription(
''' '''
# Publish a message to the topic # Publish a message to the topic
# Read the data from the csv file # Read the data from the csv file
file_path = "C:/Users/Karen/Desktop/zipcodes.csv" # file_path = "C:/Users/Karen/Desktop/zipcodes.csv"
file_path = "zipcodes.csv"
with open(file_path, "r") as csv_file: with open(file_path, "r") as csv_file:
reader = csv.reader(csv_file) reader = csv.reader(csv_file)
@@ -60,4 +60,4 @@ async def receive_messages():
asyncio.run(receive_messages()) asyncio.run(receive_messages())
''' '''
+5 -4
View File
@@ -3,8 +3,9 @@ import csv
import os import os
import asyncio import asyncio
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "C:/Users/Karen/AppData/Roaming/gcloud/application_default_credentials.json" # os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "C:/Users/Karen/AppData/Roaming/gcloud/application_default_credentials.json"
project_id = "fp-20230425" # project_id = "fp-20230425"
project_id = "svig-384801"
''' '''
topic_name = "fp-topic-NFL-zipcodes" topic_name = "fp-topic-NFL-zipcodes"
@@ -37,11 +38,11 @@ subscription_path = subscriber.subscription_path(project_id, subscription_name)
subscription = subscriber.create_subscription( subscription = subscriber.create_subscription(
name=subscription_path, topic=topic_path name=subscription_path, topic=topic_path
) )
''' '''
# Publish a message to the topic # Publish a message to the topic
# Read the data from the csv file # Read the data from the csv file
file_path = "C:/Users/Karen/Desktop/NFL_Cities.csv" # file_path = "C:/Users/Karen/Desktop/NFL_Cities.csv"
file_path = zipcodes.csv
with open(file_path, "r") as csv_file: with open(file_path, "r") as csv_file:
reader = csv.reader(csv_file) reader = csv.reader(csv_file)