Tuesday, February 15, 2022

[google-cloud-sql-discuss] Re: Problem with importContext always import csv header

Hello Jamir, 

The easiest way to avoid importing the header row were to simply edit it out from the CSV file. There are other options; you may check, for instance, When importing a CSV from Google Storage into Google SQL is there a way to skip the first row?

On Saturday, 12 February 2022 at 12:52:21 UTC-5 jamir.hua...@gmail.com wrote:
I have a csv file with a header, whenever I import the csv, the header is imported as one more record in the table

uri = "gs://mybucket/backup/mysql-000000000000.csv"          
            body = {
                "importContext": {
                    "kind": "sql#importContext",
                    "fileType": "CSV",
                    "uri": uri,
                    "database": 'mydbname',
                    "csvImportOptions": {
                        "table": 'mytable'
                    }
                }
            }
            request = self.service_sql.instances().import_(project='myproject', instance='myinstance', body=body)
            response = request.execute()

Is there a way to import the csv without header using any option? or I should pass the csv without header?

Thank

--
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/d16c21c5-b2ba-46dd-b167-fc4f95537928n%40googlegroups.com.

No comments:

Post a Comment