Share via

Query .csv file using Serverless Pool Synapse

39861377 141 Reputation points
2023-03-09T09:20:43.8966667+00:00

Hi,

I'm trying to query a .csv file stored in blob storage using Serverless Pool. None of the fields in the file have quoted strings. When querying it throws error. The file is '|' pipeline delimited.

User's image

Azure Synapse Analytics
Azure Synapse Analytics

An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.


2 answers

Sort by: Most helpful
  1. 39861377 141 Reputation points
    2023-03-10T07:20:22.8366667+00:00

    Hi @Bhargava Gunnam , @Jaison Menezes

    Found that a quote character can be escaped using another character. So I used '=' as the quote character since it was not appearing in any of the values.

    SELECT
        TOP 100 *
    FROM
        OPENROWSET(
            BULK 'https://<storage>.blob.core.windows.net/Customer/Customer_2023-03-08_07-30.csv',
            FORMAT = 'CSV',
            PARSER_VERSION = '2.0',
            FIELDTERMINATOR = '|',
            HEADER_ROW=TRUE,
            FIELDQUOTE = '='
        ) AS [result]
    
    

    Was this answer helpful?

    1 person found this answer helpful.

  2. Jaison Menezes 0 Reputation points
    2023-03-10T06:13:46.0866667+00:00

    Yes you can use double quotes in CSV in order to escape the double quotation marks try to enclose them within another double quotation mark.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.