+ Reply to Thread
Results 1 to 23 of 23

Format Text file for Excel

  1. #1
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    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 04: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
    649

    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
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    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
    649

    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
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    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
    649

    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
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    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
    649

    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
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    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
    649

    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
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    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
    649

    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
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    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 Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    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.
    Entia non sunt multiplicanda sine necessitate

  15. #15
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    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

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

    Re: Format Text file for Excel

    I can answer that question, but you can get the answer from the online help. Put your cursor in the UBound word and press F1. See what happens. Great feature of VBA.

    I am almost thru with the parser. Please watch the forum rules so we don't get shut down.

  17. #17
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    Re: Format Text file for Excel

    Blane245,

    Thanks, that is a great feature, I am going to find that useful.

    Yes, I will need to watch the rules, I just plain forgot about the code tags.

    Thanks, wow you are very quick at VBA.

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

    Re: Format Text file for Excel

    OK, bigroo, here's the whole thing. I have run it for you so you can see what it outputs. the only thing that I didn't do was to make the column and row formats pretty. You said you were going to send this to Access, so that isn't a big deal.

    I did one thing that you may want to change - I removed all of the blank lines from the messages. If they are significant, you can add them back in.

    Enjoy

    BTW, I spent some of my life in Texas (Houston, Tyler, Liberty). I miss it sometimes.ACARS Parser.xls

  19. #19
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    Re: Format Text file for Excel

    Blane 245,

    Thanks so much, this is what I want.

    One thing, the date is not in US format, can we reverse this, this was last Wednesday's file run.

    You lived in Texas, I guess you miss the warm weather then!!

    Thanks

  20. #20
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Format Text file for Excel

    Bigroo,

    Please edit your post to add code tags.

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

    Re: Format Text file for Excel

    Here ya go.ACARS Parser.xls

  22. #22
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    Re: Format Text file for Excel

    Blane245,

    Thanks for your efforts, everything looks good and is exactly as asked for.

    I really need to spend more time on VBA to get a handle on this language, I am finding many opporunities I can use code to do simply tasks.

    Thanks so much and I look forward to tapping into your knowledge further.

    James Niven
    Austin, Texas

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

    Re: Format Text file for Excel

    Spend a little time with this macro as a learning tool and don't forget to close this thread.

+ 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.6.0 RC 1