首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在BIML脚本中将csv文件中的所有双引号替换为空

在BIML脚本中将csv文件中的所有双引号替换为空
EN

Stack Overflow用户
提问于 2021-04-12 07:01:43
回答 1查看 41关注 0票数 0

我正在使用BIML导入平面文件连接。"用于文本周围,;用作分隔符。但是,在一些文件中,我看到了以下内容:

代码语言:javascript
复制
;"this is valid text""";

双引号是双引号,两者之间没有任何内容。如果我编辑该文件并搜索&将所有双引号替换为空,则导入运行良好。那么,在BIML中是否可以自动执行此操作?搜索"“的所有实例并将其替换为?

代码语言:javascript
复制
<#
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>
    <#    }    #>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-20 11:20:18

结果发现我找错地方了。转到读取文件并添加.Replace("\"\"","")的部分。

myColumns =myFile.ReadLine().Replace(“,”“).Replace(分隔符,”“).Split(分隔符);

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67053895

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档