|
|
#1 |
|
Addicted Member
Join Date: May 06
Location: Manchester, England
Posts: 255
![]() |
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. |
|
|
|
|
|
#2 |
|
Frenzied Member
Join Date: Oct 05
Location: Somewhere just west of the Atlantic
Posts: 1,565
![]() ![]() ![]() ![]() |
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
![]() Code Contributions: PHP PHP Image Gallery v1.0 • PHP Image Gallery v2.0 VB 2005 Find Computers on a network • Simple License Encryption • SQL Server Database Access dll • Use Reflection to Return Crystal ReportDocument • Silently Print PDF • Generic Xml Serailizer Useful Links: (more to come) MSDN (The first and foremost) • MSDN Design Guidelines • API Reference • Inno Setup Compiler • Inno Setup Preprocessor • ISTool - Fairly easy to use GUI for creating inno setup projects • Connection Strings • NAnt -Automated Builds • Cruise Control .NET - Frontend for automated builds
|
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|