@@ -528,6 +528,7 @@ def send_data_to_sheets(
528
528
:param input_option: Specified input option, `RAW` by default
529
529
:param client: Google Sheets client
530
530
:param is_overwrite: Overwrite option, defaults to `True`
531
+ :param is_fill_in_nulls: replace nulls with blanks, default to `False`
531
532
:return: Google Sheets API response
532
533
"""
533
534
@@ -602,21 +603,25 @@ def copy_file(file_id: str, new_file_name: str = None, client: Resource = None)
602
603
603
604
return new_file_id
604
605
605
- def upload_file_to_drive (local_path : str ,
606
- gdrive_file_name : str ,
607
- existing_mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ,
608
- gdrive_mime_type = 'application/vnd.google-apps.spreadsheet' ,
609
- permissions = [{
610
- "type" : "domain" ,
611
- "role" : "reader" ,
612
- "domain" : "staclabs.io" ,
613
- }],
614
- client : Resource = None
615
- ) -> str :
616
- """
617
- Uploads a local file to Google Drive.
618
-
619
- By default, it uploads an Excel file and converts it to a Google Sheet. Specify the
606
+
607
+ def upload_file_to_drive (
608
+ local_path : str ,
609
+ gdrive_file_name : str ,
610
+ existing_mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ,
611
+ gdrive_mime_type = "application/vnd.google-apps.spreadsheet" ,
612
+ permissions = [
613
+ {
614
+ "type" : "domain" ,
615
+ "role" : "reader" ,
616
+ "domain" : "staclabs.io" ,
617
+ }
618
+ ],
619
+ client : Resource = None ,
620
+ ) -> str :
621
+ """
622
+ Uploads a local file to Google Drive.
623
+
624
+ By default, it uploads an Excel file and converts it to a Google Sheet. Specify the
620
625
Mime Type parameters if you want to upload a CSV to a Google Sheet, a Word doc to a
621
626
Google Doc, etc.
622
627
@@ -628,25 +633,20 @@ def upload_file_to_drive(local_path: str,
628
633
:param gdrive_file_name: Name we should give the uploaded file
629
634
:param existing_mime_type: Mime type of the local file (defaults to Excel)
630
635
:param gdrive_mime_type: Mime type of the resulting file (defaults to Google Sheets)
631
- :param permissions: Array of Google permissions objects specifying who should access the
636
+ :param permissions: Array of Google permissions objects specifying who should access the
632
637
new file. Defaults to giving everyone at stac labs read-only permissions.
633
638
:param client: Google Drive client
634
639
:return: id of the file on Google drive
635
640
"""
636
641
client = client or auth_drive ()
637
- file_metadata = {
638
- "name" : gdrive_file_name ,
639
- "mimeType" : gdrive_mime_type
640
- }
641
- media = MediaFileUpload (local_path ,
642
- mimetype = existing_mime_type ,
643
- resumable = True )
642
+ file_metadata = {"name" : gdrive_file_name , "mimeType" : gdrive_mime_type }
643
+ media = MediaFileUpload (local_path , mimetype = existing_mime_type , resumable = True )
644
644
file = (
645
- client .files ()
646
- .create (body = file_metadata , media_body = media , fields = "id" )
647
- .execute ()
648
- )
649
- fileId = file ['id' ]
645
+ client .files ()
646
+ .create (body = file_metadata , media_body = media , fields = "id" )
647
+ .execute ()
648
+ )
649
+ fileId = file ["id" ]
650
650
651
651
batch = client .new_batch_http_request ()
652
652
for perm in permissions :
0 commit comments