question

arkiboys avatar image
0 Votes"
arkiboys asked ThomasBoersma answered

reading .csv from blobstorage container

Hello,
There is a file, test.csv in the container.
In the synapse studio, I right click on this file which is in the blobstorage, and select the top 100 and it generates the automated sql to execute to read the data inside it.
When the automated openrowset query is executed, it does show the data but the csv headers are in the second row and in the first row I see C1, C2, C3, etc.
Do you know how to remove those unwanted C1, C2, C3, etc. headings?
Thank you

azure-blob-storage
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ThomasBoersma avatar image
0 Votes"
ThomasBoersma answered

Hi @arkiboys ,

You need to specify that you want to use the csv headers as columns. Here is an example:

 SELECT
     *
 FROM
     OPENROWSET(
         BULK 'https://{your-storage-account-name}.dfs.core.windows.net/data/test.csv',
         FORMAT = 'CSV',
         PARSER_VERSION='2.0',
         HEADER_ROW = TRUE -- This the setting you want
     ) AS [result]

See the docs for more info.

Hope this helps.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.