Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Darmstadt, Hessen, Germany
    Posts
    128
    Thanks
    15
    Thanked 2 Times in 2 Posts

    Import ASCII File From Main Frame... (office-2003 xp-pro)

    hi experts....

    i am lost with a rather simple thing which i just can't get to work...

    in the attached file i import data on a daily basis from main frame in the format shown...

    the first 3 digits represent the "doy" (day-of-the-year) which is quite easy to do a standard import without any code...

    now, as the year approaches its end the next doy will start with doy 001 but, the main frame output does not provide leading zeros...

    same thing when switching over to doy 010..

    how do i read data like that into an excel spreadsheet, please...

    thank you very much..

    best,
    wolfgang

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import ASCII File From Main Frame... (office-2003 xp-pro)

    You can run the following macro to create a text file STATION2.TXT with leading zeros. You can import this into Excel with the fixed width option (You could record a macro for that too)

    Sub FixText()
    Dim f1 As Integer
    Dim f2 As Integer
    Dim strLine As String
    Dim intPos As Integer
    f1 = FreeFile
    Open "STATION.TXT" For Input As #f1
    f2 = FreeFile
    Open "STATION2.TXT" For Output As #f2
    Do While Not EOF(f1)
    Line Input #f1, strLine
    intPos = InStr(strLine, " ")
    strLine = String(4 - intPos, "0") & strLine
    Print #f2, strLine
    Loop
    Close #f1
    Close #f2
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Nov 2004
    Location
    Darmstadt, Hessen, Germany
    Posts
    128
    Thanks
    15
    Thanked 2 Times in 2 Posts

    Re: Import ASCII File From Main Frame... (office-2003 xp-pro)

    hi hans...

    simply perfect....

    many thanxs...

    wolfgang

Posting Permissions

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