Tuesday, June 5, 2018

[google-cloud-sql-discuss] does import csv file support skip first row

Hi team,

I have the csv(~ 1GB) file in cloud storage bucket, that was extracted from bigquery,
I'm trying to import the csv file form GCS to cloud sql,
used "SQLAdmin.v1beta4" api by java client library,
when data load into the cloud sql, that contains the first row,
have any function or api can skip the first row?  


the csv file like as
id,name,column1,column2
1,"name",1,1


the code like as
InstancesImportRequest requestBody = new InstancesImportRequest();
ImportContext importContext = new ImportContext();
importContext.setKind("sql#importContext");
importContext.setFileType("csv");
importContext.setUri("gs://bucket/2018/06/05/myfile.csv");
importContext.setDatabase("my_database");


ImportContext.CsvImportOptions csv = new ImportContext.CsvImportOptions();
csv.setTable("tableName");
importContext.setCsvImportOptions(csv);


requestBody.setImportContext(importContext);


SQLAdmin.Instances.SQLAdminImport request =
   sqlAdmin.instances().sqladminImport("my_project_id", "database_instance", requestBody);


Operation response = request.execute();


I wish I can skip the csv file first row maybe on "ImportContext.CsvImportOptions.skipFirstRow(true)",


Sorry, English is not my native language

Thanks in advance.
Regards,

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/b6b66676-e1fb-4ca7-98a7-2ee9833f5837%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment