Spaces:
Sleeping
Sleeping
Commit
·
b4321bf
1
Parent(s):
51966dd
new code
Browse files
main.py
CHANGED
|
@@ -40,6 +40,20 @@ gcs_bucket = gcs_client.bucket(gcs_bucket_name)
|
|
| 40 |
# File path in GCS bucket
|
| 41 |
gcs_file_path = "deepak_6593/db.csv"
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
def read_csv(location="tambaram"):
|
| 45 |
global stop_reading
|
|
|
|
| 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
|