Skip to content

Import-DbaCsv Parse error with NormalizeQuotes #45

@late-chapter-lived

Description

@late-chapter-lived

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

When importing a file that has smart quotes and using the NormalizeQuotes switch, the default behavior is QuoteMode Strict.
This leads to CSV parse errors if there is more than one smart quote. If QuoteMode is set to Lenient, the import is processed.

Exception:
  Line |
105077 |          throw $records[0]
       |          ~~~~~~~~~~~~~~~~~
       | CSV parse error

Steps to Reproduce

@'
A,B
"“”",""
'@ | Set-Content -Path normalize.csv
$importParams = @{
  Path                     = "normalize.csv"
  SqlInstance              = $server
  Database                 = $db
  Table                    = 'NormalizeStrict'
  AutoCreateTable          = $true
  EnableException          = $true
  NormalizeQuotes          = $true
  QuoteMode                = 'Strict' # Default
}
Import-DbaCsv @importParams

Please confirm that you are running the most recent version of dbatools

2.7.25

Other details or mentions

No response

What PowerShell host was used when producing this error

PowerShell Core (pwsh.exe)

PowerShell Host Version

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

SQL Server Edition and Build number

Microsoft SQL Server 2022 (RTM-GDR) (KB5073031) - 16.0.1165.1 (X64) Nov 24 2025 19:08:45 Copyright (C) 2022 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2025 Datacenter Azure Edition 10.0 (Build 26100: ) (Hypervisor)

.NET Framework Version

.NET 9.0.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions