Spaces:
Sleeping
Sleeping
Commit
·
7bb0628
1
Parent(s):
b4321bf
new code
Browse files
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
|
| 44 |
-
def
|
| 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 |
-
#
|
| 51 |
-
if
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
|
| 55 |
# Check and create file before endpoint is accessed
|
| 56 |
-
|
| 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
|