deepak6593 commited on
Commit
7bb0628
·
1 Parent(s): b4321bf
Files changed (1) hide show
  1. main.py +9 -7
main.py CHANGED
@@ -40,20 +40,22 @@ gcs_bucket = gcs_client.bucket(gcs_bucket_name)
40
  # File path in GCS bucket
41
  gcs_file_path = "deepak_6593/db.csv"
42
 
43
- # Function to check if file exists in GCS bucket
44
- def check_create_file():
45
  # Initialize GCS client
46
  gcs_client = storage.Client()
47
  gcs_bucket = gcs_client.bucket(gcs_bucket_name)
48
  blob = gcs_bucket.blob(gcs_file_path)
49
 
50
- # Check if file exists
51
- if not blob.exists():
52
- # Create an empty file
53
- blob.upload_from_string("", content_type="text/csv")
 
 
54
 
55
  # Check and create file before endpoint is accessed
56
- check_create_file()
57
 
58
  def read_csv(location="tambaram"):
59
  global stop_reading
 
40
  # File path in GCS bucket
41
  gcs_file_path = "deepak_6593/db.csv"
42
 
43
+ # Function to create an empty file in GCS bucket
44
+ def create_empty_file():
45
  # Initialize GCS client
46
  gcs_client = storage.Client()
47
  gcs_bucket = gcs_client.bucket(gcs_bucket_name)
48
  blob = gcs_bucket.blob(gcs_file_path)
49
 
50
+ # Delete file if it exists
51
+ if blob.exists():
52
+ blob.delete()
53
+
54
+ # Create an empty file
55
+ blob.upload_from_string("", content_type="text/csv")
56
 
57
  # Check and create file before endpoint is accessed
58
+ create_empty_file()
59
 
60
  def read_csv(location="tambaram"):
61
  global stop_reading