परिणाम डाउनलोड करें

अपलोड की गई स्ट्रक्चर्ड डेटा फ़ाइल के प्रोसेस हो जाने के बाद, media.download का इस्तेमाल करके, दी गई संसाधन की जगह से ZIP फ़ाइल डाउनलोड करें.

आपके लिए यह काम करती हैं.

यहां फ़ाइल की जगह ढूंढने और ZIP फ़ाइल डाउनलोड करने का तरीका बताया गया है:

# Import the object used for media download.
from googleapiclient import http as googleHttp
import io

# Provide the name of the successfully completed sdfuploadtask operation.
operation_name = operation-name

# Provide the path for the output file.
output_path = output-path

# Retrieve the completed operation.
operation = service.sdfuploadtasks().operations().get(operation_name).execute()

# Retrieve the file location from the operation.
file_location = operation["response"]["resourceName"]

# Configure the media.download request.
download_request = service.media().download_media(resourceName=file_location)

# Create output stream for downloaded file.
out_stream = io.FileIO(output_path, mode='wb')

# Build downloader object.
downloader = googleHttp.MediaIoBaseDownload(out_stream, download_request)

# Download file in chunks until finished.
download_finished = False
while download_finished is False:
  _, download_finished = downloader.next_chunk()

print(f'File downloaded at {output_path}.')

फ़ाइलें एक्सट्रैक्ट करना

डाउनलोड की गई ZIP फ़ाइल को डीकंप्रेस करें, ताकि एसडीएफ़ अपलोड करने के नतीजे निकाले जा सकें. नतीजे की एक या दोनों फ़ाइलें मौजूद हो सकती हैं. इनमें {EntityName}, संसाधन का टाइप होता है. जैसे, LineItems:

  • SDF-{EntityName}-Updated-ResultFile.csv, जिसमें उन संसाधनों की सूची होती है जिन्हें बनाया या अपडेट किया गया है
  • SDF-{EntityName}-Failed-ResultFile.csv, जिसमें उन संसाधनों की सूची दी गई है जिन्हें अपडेट या बनाया नहीं जा सका. साथ ही, गड़बड़ी का मैसेज भी दिया गया है.