To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic .NET

Reply Post New Thread
 
Thread Tools Display Modes
Old Nov 10th, 2006, 06:30 AM   #1
penguin5000
Addicted Member
 
Join Date: May 06
Location: Manchester, England
Posts: 255
penguin5000 is an unknown quantity at this point (<10)
Question Transfer messy text file to datagrid

Hi,
I'm working on a small utility for my employer whereby I need to read in the contents of a text file, put it into a datagrid, and sum the totals for two of the columns.
I've had a quick look around, and all I keep on finding is reference to the 'split' command.
The problem is that there are no definitive splits in the text file.
The source text file is really messy, but it does have a structure that I hope I can work with. I have worked out that the lines I need to import all begin with a single character, "K". The columns (on these lines beginning with "K") that I need to import and work with, for example, start on character number 8, which references a product code, and is (for example) 8 characters in length. The next 'column' of information starts on character number 20, and is a numeric value covering 10 chars. Immediately after this 'column' (no spaces in between!) is another numeric value - again 10 characters in length.
What I want to do is put this data into a datagrid, and sum the numeric columns.
Any help would be appreciated.
penguin5000 is offline   Reply With Quote
Old Nov 10th, 2006, 07:33 AM   #2
bmahler
Frenzied Member
 
bmahler's Avatar
 
Join Date: Oct 05
Location: Somewhere just west of the Atlantic
Posts: 1,565
bmahler is a jewel in the rough (300+)bmahler is a jewel in the rough (300+)bmahler is a jewel in the rough (300+)bmahler is a jewel in the rough (300+)
Re: Transfer messy text file to datagrid

If the columns you need are always in the same position in the relevant lines then you can just read each line until you find a K then break that line up using substrings, starting at the position of the item you want and reading for x number of characters and so-on.
__________________
Boooya
  • Visual Studio 2008 Professional
  • Don't forget to use [CODE]your code here[/CODE] when posting code
  • Don't forget to rate helpful posts!
  • If you're question was answered please mark your thread [Resolved]

Code Contributions:
PHP
PHP Image Gallery v1.0PHP Image Gallery v2.0
VB 2005
Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


Useful Links: (more to come)
MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds
bmahler is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic .NET


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:24 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.