Ich versuche, eine lokale CSV-Upload große Abfrage mit PythonWie eine lokale CSV-Upload große Abfrage Google Python mit
def uploadCsvToGbq(self,table_name):
load_config = {
'destinationTable': {
'projectId': self.project_id,
'datasetId': self.dataset_id,
'tableId': table_name
}
}
load_config['schema'] = {
'fields': [
{'name':'full_name', 'type':'STRING'},
{'name':'age', 'type':'INTEGER'},
]
}
load_config['sourceFormat'] = 'CSV'
upload = MediaFileUpload('sample.csv',
mimetype='application/octet-stream',
# This enables resumable uploads.
resumable=True)
start = time.time()
job_id = 'job_%d' % start
# Create the job.
result = bigquery.jobs.insert(
projectId=self.project_id,
body={
'jobReference': {
'jobId': job_id
},
'configuration': {
'load': load_config
}
},
media_body=upload).execute()
return result
wenn ich laufe dies wirft Fehler wie
to google"NameError: global name 'MediaFileUpload' is not defined"
ob ein modul benötigt wird bitte helfen.
Woher haben Sie den Klassennamen 'MediaFileUpload'? – LeeNeverGup
http://stackoverflow.com/questions/25048787/loading-json-file-in-bigquery-using-google-bigquery-client-api Ich versuchte dieses Beispiel – Teejay