Solved

import fixed width text file

Posted on 2011-03-14
5
952 Views
Last Modified: 2012-05-11
Hi,
What is the best way to process a fixed width text file?
I have about 8 columns and need to read row by row. Using a stream reader or is it possible to read it into a dataset?
0
Comment
Question by:CraigLazar
5 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 63 total points
Comment Utility
I think you would need to read it via a stream reader.  You could create an in memory dataset and populate that if your processing of the file contents is better suited to that.
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 63 total points
Comment Utility
You've tagged this question in VB and C#, so not sure which you are using. If it is VB then this might be an alternative to manually parsing each line:

    http://msdn.microsoft.com/en-us/library/zezabash.aspx
0
 
LVL 11

Assisted Solution

by:Kusala Wijayasena
Kusala Wijayasena earned 62 total points
Comment Utility
Hi Craig,

StreamReader with adjusted buffer size will improve your performance by requiring minimal memory foot print. On the other hand, if you load your data into dataset, it will take much bigger memory allocation (as same size of the physical file).

So if your requirement is to process line by line, then go for StreamReader. Or else, if you required all the records available in memory at the point of processing, dataset would be the option to follow

-Kusala
0
 
LVL 12

Assisted Solution

by:Mohamed Abowarda
Mohamed Abowarda earned 62 total points
Comment Utility
If you are trying to split text file to string array (each array item will contain one line) you can use StringReader, TextReader or StreamReader to read the file in the variable "fileContents" and use the following code:
Dim strArray() As String = Split(fileContents, vbNewLine)

Open in new window

0
 
LVL 4

Author Closing Comment

by:CraigLazar
Comment Utility
Hi Guys,
thanks for the input, all helped
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now