如何解决用BIML脚本的csv文件中的任何内容替换所有双引号
我正在使用 BIML 导入平面文件连接。
"
用于文本周围,;
用作分隔符。
但是,在某些文件中,我看到了这一点:
;"this is valid text""";
有双双引号,中间没有任何内容。如果我编辑文件并搜索并替换所有双双引号,则导入运行良好。那么,是否可以在 BIML 中自动执行此操作?搜索 "" 的所有实例并将它们替换为 ?
<#
string[] myFiles = Directory.GetFiles(path,extension);
string[] myColumns;
// Loop trough the files
int TableCount = 0;
foreach (string filePath in myFiles)
{
TableCount++;
fileName = Path.GetFileNameWithoutExtension(filePath);
#>
<Package Name="stg_<#=prefix#>_<#=TableCount.ToString()#>_<#=fileName#>" ConstraintMode="Linear" AutoCreateConfigurationsType="None" ProtectionLevel="<#=protectionlevel#>" PackagePassword="<#=packagepassword#>">
<Variables>
<Variable Name="CountStage" DataType="Int32" Namespace="User">0</Variable>
</Variables>
<Tasks>
<ExecuteSQL ConnectionName="STG_<#=application#>" Name="SQL-Truncate <#=fileName#>">
<DirectInput>TRUNCATE TABLE <#=dest_schema#>.<#=fileName#></DirectInput>
</ExecuteSQL>
<Dataflow Name="DFT-Transport CSV_<#=fileName#>">
<Transformations>
<FlatFileSource Name="SRC_FF-<#=fileName#> " ConnectionName="FF_CSV-<#=Path.GetFileNameWithoutExtension(filePath)#>">
</FlatFileSource>
<OleDbDestination ConnectionName="STG_<#=application#>" Name="OLE_DST-<#=fileName#>" >
<ExternalTableOutput Table="<#=dest_schema#>.<#=fileName#>"/>
</OleDbDestination>
</Transformations>
</Dataflow>
</Tasks>
</Package>
<# } #>
解决方法
事实证明,我完全看错了地方。
去了文件读取和添加的部分.Replace("\"\"","")
myColumns = myFile.ReadLine().Replace("""","").Replace(separator,"").Split(delimiter);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。