Dbatools: Possible bug in Import-DbaCsvToSql/Import-DbaCsv with double quote char

Created on 25 Dec 2018  路  3Comments  路  Source: sqlcollaborative/dbatools

Before submitting a bug report:

  • [X] Ensure you are able to reproduce it on the latest released version (_we release often_)
  • [X] Verified this bug is not already reported in an issue
  • [X] Verified errors are not related to permissions
  • [X] Can reproduce in a clean PowerShell session (_clean = powershell -NoProfile_)

Steps to Reproduce

Import-DbaCsvToSql -SqlInstance SRV1 -Database DB1 -Table tblFin -Delimiter ';' -Path E:\CVSFiles\1.csv
field1;field2;field3
abbcc;bbccdd;"ccddee

Expected Behavior

Imports CSV file w/o errors

Actual Behavior

WARNING: [xx:xx:xx][Import-DbaCsv] Failure | The CSV appears to be corrupt near record '498663' field '3 at position '0'. Current raw data : 'N'.

Actually, that line contains a single double quote character ".

Most helpful comment

K i got it working with another option

gci E:\csv\zh.csv | Import-DbaCsv -SqlInstance sql2017 -Database tempdb -AutoCreateTable -Delimiter ';' -Quote $null

This will be available in the next release, due out today 馃憤馃巹

All 3 comments

hey oleg,
right off, that seems like malformed data to me and the parser but! I just added TrimmingOption to the branch in PR #4881 - try that and see if it helps

K i got it working with another option

gci E:\csv\zh.csv | Import-DbaCsv -SqlInstance sql2017 -Database tempdb -AutoCreateTable -Delimiter ';' -Quote $null

This will be available in the next release, due out today 馃憤馃巹

Thank you so much!!!

Was this page helpful?
0 / 5 - 0 ratings