+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: Format Text file for Excel

  1. #1
    Registered User
    Join Date
    11-27-2009
    Location
    Cedar Creek (Austin), Texas
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    45

    Format Text file for Excel

    Hi All,

    I am thinking maybe I should work on this file in Excel and then import into Access, so I am moving this post/message from Access Programming to here, so I hope I am not breaking any rules.

    I have a large text file that is generated daily and want to import into MS Access as the end result.

    First I need to reformat into the row format in excel rather than the format it is in. The issue is not all the segments are the same number of lines or they may have mutli message lines. The names with colon : after them I want to be field names in the table which I wish the text file to import into. Please, I am looking for assistance with this.

    I have attached sample data of the text dump, and the name of the file is as you see but different date on the end. At the very end of the text file you will see the desired output which I will then import into Access

    Also every new message begins with the dotted line and the date and time at the end.

    I hope this makes sense to those offering assistance, if you have questions please ask them.

    James Niven
    Austin, Texas
    Attached Files Attached Files
    Last edited by bigroo1958; 01-12-2010 at 03:58 PM. Reason: Closed Thread

  2. #2
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    641

    Re: Help with formatting Text file for Excel

    Not sure why you want to use Excel as an intermediate for this problem. Any macro to load the data into Excel would be very similar to the one in Access. If you need an Excel file, you could export the table out of Access into Excel.

  3. #3
    Registered User
    Join Date
    11-27-2009
    Location
    Cedar Creek (Austin), Texas
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    45

    Re: Help with formatting Text file for Excel

    Blane 245,

    Ok, I understand what you are saying, export the table out of Access, but have you looked at the format the text file is in, it is not a straight copy and paste into a table. Can you assist me with this?

    James
    (ex-aussie from Brisbane)

  4. #4
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    641

    Re: Help with formatting Text file for Excel

    Sorry, don't have an ACARS parser handy. Looks like a straightforward parsing problem, though. You might check web sites like http://www.acarsd.org/ to see what they have to offer.

  5. #5
    Registered User
    Join Date
    11-27-2009
    Location
    Cedar Creek (Austin), Texas
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    45

    Re: Help with formatting Text file for Excel

    Blane245,

    Thanks for the reply, I have done that and there is nothing available, unless I buy a Log Analyser program. I just wish to use Access to make my own log analyser.
    I am not too good in VBA, so looking for assistance.

    Thanks

    James

  6. #6
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    641

    Re: Help with formatting Text file for Excel

    I can guide you through this, but I need to know how much experience you have with VBA before we get started. Have you written any VBA macros?

  7. #7
    Registered User
    Join Date
    11-27-2009
    Location
    Cedar Creek (Austin), Texas
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    45

    Re: Help with formatting Text file for Excel

    Blane 245,

    I have done a little VBA, still in the beginner steps, though I am very willing to learn.
    Where do we start and what information do you require from me?

    James

  8. #8
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    641

    Re: Help with formatting Text file for Excel

    First, which of the ACARS keywords are you interested in? The ones that I see in your sample file are
    ACARS Mode
    Aircraft reg
    Aircraft type
    Message Label
    Message Number
    Flight Number
    Operator
    Message Content

    Are you also interested in extracting the date/time stamp on each message?

  9. #9
    Registered User
    Join Date
    11-27-2009
    Location
    Cedar Creek (Austin), Texas
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    45

    Re: Help with formatting Text file for Excel

    Blane 245,

    Yes, you have it right, the date stamp and time is needed. If you look at the bottom of the attached text file you will see the desired output I wish and fields needed as well.

    Thanks for your assistance!!

  10. #10
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    641

    Re: Help with formatting Text file for Excel

    OK. so let's get started. Attached is a workbook that is the start of the file parser. All I have now is the code to open the file and create a new worksheet in the current workbook. See if you can follow it.

    The workbook has a Notes sheet that contains some info on how the parser will work.

    It also has a Run Sheet worksheet that hold the button to start the execution and the name of the file to parse.

    Let me know if you're with me on this. Do I need to explain anything further?

    ACARS Parser.xls

  11. #11
    Registered User
    Join Date
    11-27-2009
    Location
    Cedar Creek (Austin), Texas
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    45

    Re: Help with formatting Text file for Excel

    Blane245,

    Ok, so far I am with you. The only thing I see at the moment is to change the folder loaction to suit my environment, but this is minor.

    OK, please proceed!!

  12. #12
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    641

    Re: Format Text file for Excel

    Great! The parser will take a little longer. Here's the next cut. You will see the skeleton of the parser. The code should run without problem, reading the entire file, but not doing anything with it.

    Let me know if you need any clarification.
    ACARS Parser.xls

  13. #13
    Registered User
    Join Date
    11-27-2009
    Location
    Cedar Creek (Austin), Texas
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    45

    Re: Format Text file for Excel

    Blane245,

    Great Job, I really appreciate this effort!!

    In this poart of the code:

    Dim r As Long ' the current row
    Dim i As Integer ' keyword index

    r = 1
    With wSheet
    ' write the headers onto the first rwo of the sheet
    .Cells(r, 1).Value = "Date"
    .Cells(r, 2).Value = "Time"
    For i = 0 To UBound(Keywords, 1)
    .Cells(r, 3 + i) = Keywords(i)
    Next i

    Ok R is setting up the row starting at 1, but what is UBound?

    Thanks

  14. #14
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Format Text file for Excel

    Bigroo, please take a few minutes to read the forum rules, and then edit your post to add code tags.

    Thanks.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  15. #15
    Registered User
    Join Date
    11-27-2009
    Location
    Cedar Creek (Austin), Texas
    MS-Off Ver
    Excel 2003 & Excel 2007
    Posts
    45

    Re: Format Text file for Excel

    Shg,

    Thanks for the heads up. I will watch this next time.

    Your in Texas, where abouts?
    I am in Austin!

    Thanks

    James

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0