SSIS无法识别{CR} {LF} [英] SSIS not recognizing {CR}{LF}

查看:105
本文介绍了SSIS无法识别{CR} {LF}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试写一个SSIS包的主要问题。 SSIS包应该读取csv文件并将其导入表中。我遇到的问题是文件来到我的前15行左右用{CR} {LF}终止。

1,123,11,0,0,0,0 ,,, 0000-00-00,

2,123,11,0,0,0,0 ,,, 0000-00-00,

然后在前15行后,行终止变为简单的{CR} {LF}。

16,123,11,12,0,0,0 ,,, 0000-00-00

我遇到的问题是在第16行SSIS无法识别{CR} {LF}并开始将行合并在一起,因此第16行和第17行显示为一行,第18行和第19行显示为一行,等等。据我所知,它不能识别第16行末尾的{CR} {LF},但后来识别第17行末尾的{CR} {LF}。它没有任何意义。我有一个脚本在处理文件之前运行以删除未转义的引号。

strInput = File。 ReadAllText(strFilePath& " \ Project_Task.csv" ,System.Text.Encoding.ASCII)

strInput = strInput.Replace(Chr (34)& Chr(34), ""

strInput = strInput.Replace(Chr(34) & Chr(34), "")

File.WriteAllText(strFilePath& < font face ="Geneva,Arial,Sans-serif"> " \Project_Task.csv" ,strInput)

File.WriteAllText(strFilePath & "\Project_Task.csv", strInput)

我尝试添加以下行来尝试删除{CR} {LF}并将其替换为简单的{CR} {LF},但这只是工作很重要然后,所有行都会发生行合并。

strInput = strInput.Replace(QUOT;," &安培; vbCrLf,vbCrLf)

使用TextPad我查看了原始的CSV文件并确定它是用ASCII编码的,我不知道为什么会发生这种情况。如果我在excel中打开文件它格式正确,如果我使用SSIS,则格式化会被抛弃。该文件是一个简单的.CSV,文本限定符为"列的分隔符,以及{CR} {LF}的行分隔符。

Using TextPad I looked at the original CSV file and determined that it was encoded in ASCII, I am at a loss as to why this is happening.  If I open the file in excel it formats correctly, if I use SSIS the formating gets thrown off.  The file is a simple .CSV with a text qualifier of " column delimeter of , and a row delimeter of {CR}{LF}.

Anyhelp将不胜感激。

Anyhelp would be appreciated.

推荐答案

您的文件无效,您无法更改数量列,由分隔符定义,在文件的一半。

Your file is invalid, you cannot change the number of columns, as defined by the delimiters, half way through a file.

1,123,11,0,0,0,0 ,,, 0000-00-00,= 11列

1,123,11,0,0,0,0,,,0000-00-00, = 11 Columns

1,123,11,0,0,0,0 ,,, 0000-00-00 = 10列

1,123,11,0,0,0,0,,,0000-00-00 = 10 Columns

将文件格式定义为只有10列。要执行此操作,请转到"平面文件连接",然后选择"高级"页面,并删除"第10列",第11列,因为名称是基于索引的。如果您的文件包含列名,则可以将其称为其他内容。

Define your file format as only having 10 columns. To do this go into the Flat File Connection, and select the Advanced page, and delete "Column 10", the 11th column as the names are index based. It may be called something else if your file included column names.

您的10列现在将包含这样的值 -

Your 10 column will now contain values like this-

0000-00-00 ,




0000-00-00,
0000-00-00
0000-00-00
0000-00-00,

然后你可以添加一个派生列变换来检查内容最后一列,根据需要设置列的条带,如果你想匹配原始格式,甚至可以添加第11列。

You can then add a Derived Column Transform to check the contents of this last column, and strip of the column as required, or even add a 11th column if you wanted to match the orginal format.


这篇关于SSIS无法识别{CR} {LF}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆