导入非分隔文本文件SSIS [英] Import Non delimited Text File SSIS

查看:73
本文介绍了导入非分隔文本文件SSIS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下格式的文本文件:



89898 ABCF-ASDAS 23.88

45334 MJKI-OP MKLDFMK 89.88


如何使用平面文件源连接从上述格式中读取?我可以使用哪些参数来读取上面的格式化文件?需要帮助。

解决方案

假设空格字符只能用作分隔符,您可以一次读取一行平面文件,然后按空格分割



 使用(StreamReader sr = File.OpenText(Filepath))< span class =code-comment> //  <  -  Filepath here  
{
string line = String .Empty;
while ((line = sr.ReadLine())!= null
{


// 按空格划分
string [] values = line.Split(' ' );
MessageBox.Show(values [ 0 ]) // 第一轮将返回89898
MessageBox.Show(values [ 1 ]) // 第一轮将返回ABCF-ASDAS
MessageBox.Show(values [ 2 ]) // 第一轮将返回23.88

}


I have text files with the below format:

89898 ABCF-ASDAS 23.88
45334 MJKI-OP MKLDFMK 89.88

How to read from the above format using flat file source connection? which parameters I can use to read the above formatted file? Help needed.

解决方案

Assuming the only time the space character can be used as the delimiter you can read your flat file one line at a time, then split by Space

using (StreamReader sr = File.OpenText(Filepath)) //<-- Filepath here
                {
                    string line = String.Empty;
                    while ((line = sr.ReadLine()) != null)
                    {
     
                  
                        //split by SPACE
                        string[] values = line.Split(' ');
                MessageBox.Show(values[0]) // first time round would return 89898 
                MessageBox.Show(values[1]) // first time round would return ABCF-ASDAS
                MessageBox.Show(values[2]) // first time round would return 23.88      
  
                    }


这篇关于导入非分隔文本文件SSIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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