Results 1 to 2 of 2

Thread: Transfer messy text file to datagrid

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    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.

  2. #2
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width