2

我正在尝试使用 Liquibase 更改日志集将 CSV 文件加载到 SQLserver 表中。当将 XLSX 文件保存为 CSV 文件时,包含逗号的列保存在双引号中(请参见下面的第三个值),按照标准这很好,但 liquibase 忽略双引号并考虑双引号内的逗号。

13,OV,糖尿病门诊自我管理培训服务个体,每30分钟”,77.82,1,0,1/4/2016,,G0108

来自命令行终端的错误消息:


CSV 文件 v2.1/r21/TestData20212021.csv 第 21 行定义了 10 个值,标题有 9 个。数字必须相等(检查带有嵌入逗号的未引用字符串)


<changeSet  author="sprint-developer" id="sprint1-09">

<loadData 
file="v2.1/r21/TestData2021.csv" 
 tableName = "tbl_Votes" encoding="UTF-8"   >  

 <column header="VcenarioID" name="VcenarioID" type="numeric"/>
     <column header="venefitCode" name="venefitCode" type="string"/>
     <column header="KostDescription" name="KostDescription" type="string"/>
     <column header="Kost" name="Kost" type="NUMERIC"/>
     <column header="OcKurrences" name="OKcurrences" type="numeric"/>
     <column header="KostIsPerIncident" name="KostIsPerIncident" type="boolean"/>
     <column header="KostDate" name="KostDate"  type="date"/>
     <column header="VundleId" name="VundleId"  type="NUMERIC"/>
     <column header="VillingCode" name="VillingCode" type="string"/>
    </loadData>
 <rollback>Delete from tbl_Votes where VcenarioID=13 </rollback>
</changeSet> 
4

1 回答 1

1

尝试添加quotchar='"'到您的变更集。这应该告诉 liqbuiase 将内部的所有内容都""视为一个值。

查看loadData文档。

因此,您的 changeSet 可能如下所示:

<changeSet  author="sprint-developer" id="sprint1-09">
    <loadData
            file="v2.1/r21/TestData2021.csv"
            tableName = "tbl_Votes" encoding="UTF-8" quotchar='"'>

        <column header="VcenarioID" name="VcenarioID" type="numeric"/>
        <column header="venefitCode" name="venefitCode" type="string"/>
        <column header="KostDescription" name="KostDescription" type="string"/>
        <column header="Kost" name="Kost" type="NUMERIC"/>
        <column header="OcKurrences" name="OKcurrences" type="numeric"/>
        <column header="KostIsPerIncident" name="KostIsPerIncident" type="boolean"/>
        <column header="KostDate" name="KostDate"  type="date"/>
        <column header="VundleId" name="VundleId"  type="NUMERIC"/>
        <column header="VillingCode" name="VillingCode" type="string"/>
    </loadData>
    <rollback>Delete from tbl_Votes where VcenarioID=13 </rollback>
</changeSet>
于 2020-02-25T11:11:14.843 回答