SSIS 2005-如何导入固定宽度的平面文件? [英] SSIS 2005 - How to Import a Fixed Width Flat File?

查看:109
本文介绍了SSIS 2005-如何导入固定宽度的平面文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来像这样的平面文件:

I have a flat file that looks something like this:

junk I don't care about   \n
\n
columns names\n
val1    val2   val3\n
val1    val2   val3\n
columns names   \n
val1    val2   val3\n

我只关心带有值的行.这些值行都是固定宽度格式,并且具有相同的行长.其他垃圾行和列名可以具有任何行宽.

I only care the lines with values. These value lines are all fixed width format and have the same line length. The other junk lines and column names can have any line width.

当我尝试使用平面文件固定宽度选项或右侧参差不齐的选项时,预览看起来完全错误.有什么想法让这成为SSIS最简单的方法是什么?

When I try the flat file fixed width option or the ragged right option the preview looks all wrong. Any ideas what the easiest way to get this into SSIS is?

推荐答案

您不能使用固定宽度选项,而且我似乎还记得,只有在整个最后一栏中都有衣衫ness的情况下,衣衫right的权利选项才适用.

You cannot use the fixed width option and I seem to recall that the ragged right option only applies if the raggedness is in the entire last column.

您可以使用参差不齐的右选项,将整个内容读入字符串列,然后使用派生列.

You can use the ragged right option and read the entire thing into a string column and then use derived columns.

或者,对文件进行预处理(可能在SSIS中,使用带有条件分割的参差不齐的权利,输出到平面文件)以过滤掉要忽略的行,然后可以使用平面文件连接经理对结果文件进行操作.

Alternatively, pre-process the file (possibly in SSIS, using a ragged-right with a conditional split, outputting to a flat file) to filter out the lines you are going to ignore and then you can use the flat file connection manager on the resulting file.

另一种选择是手动编写数据源脚本任务.

Another option is to code a data source script task by hand.

如果您可以通过在其他数据流的输出上定义新的连接管理器布局来使用更复杂的文件,那将是很好的选择,但这在SSIS中目前不可用.

It would be nice if you could use more complex files by being able to define new connection manager layouts on the outputs of other data flows, but that is not currently available in SSIS.

这基本上是我在此问题中提出的相同问题:

This is basically the same problem I posed in this question: How to process ragged right text files with many suppressed columns in SSIS or other tool?

这篇关于SSIS 2005-如何导入固定宽度的平面文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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