Loading ...
Sorry, an error occurred while loading the content.

BASIC text file reformatter

Expand Messages
  • basicbasically
    Although I learned BASIC many years ago, I did not continue much programing after that unless you count customizing HyperCard and AppleScript. The folks on
    Message 1 of 4 , Mar 12, 2009
    • 0 Attachment
      Although I learned BASIC many years ago, I did not continue much programing after that unless you count customizing HyperCard and AppleScript. The folks on this forum run rings around my experience.

      However, I want to use BASIC to create a text file importer to import a specific, ridiculously long, ridiculously un-user friendly, mainframe-style report that is unavailable in any other format. It would take me so much longer to re-learn and trial & error my way to creating such a utility that I am hoping this will be trivial for some willing individuals to help me with.

      I envision opening a specific file 'A' for reads, then reading a set number of bytes and assigning to a specific variable, reading another number of bytes for the ext variable and so forth until a record is read, then write the record to file 'B'. Repeat until EOF, but of course there are inconsistencies with the report that I will have to trap for to get at the basic data I really need.

      The report is 2000 printed pages of good data formatted and presented so poorly that good information is lost in the sea of antiquity. I intend to load the resulting file into Excel, Access or FileMaker and do something real and up-to-date with it.

      I am hopeful generous individuals will be willing to help me get started.
    • jeffonymail
      ... Hi. It would seem to be much easier to open the file in a text editor such as the freeware TextWrangler and manipulate it from there. If you are
      Message 2 of 4 , Mar 14, 2009
      • 0 Attachment
        --- In chipmunkbasicforum@yahoogroups.com, "basicbasically" <basicbasically@...> wrote:
        > I want to use BASIC to create a text file importer
        > to import a specific, ridiculously long, ridiculously
        > un-user friendly, mainframe-style report that is
        > unavailable in any other format.
        >
        > The report is 2000 printed pages of good data
        > formatted and presented so poorly that good
        > information is lost in the sea of antiquity.
        > I intend to load the resulting file into Excel,
        > Access or FileMaker and do something real and
        > up-to-date with it.

        Hi.

        It would seem to be much easier to open the file in a text editor such
        as the freeware TextWrangler and manipulate it from there. If you are
        adventurous, TextWrangler also includes the immensely powerful but
        somewhat daunting grep editor although using grep is an option.

        If you really want to do it in Chipmunk, here is a simple programme to
        start with. I don't know if the large size of your file is going to
        cause you any problems.

        To start with, let's just read the first 200 lines to see that it works:

        totLines = 200
        dim theDoc$(totLines)
        open "SFGetFile" for input as #1
        for i = 1 to totLines
        if eof(#1) then exit for
        input #1, theDoc$(i)
        REM print theDoc$(i)
        next i
        close #1
        end

        .....Jeff
      • Myron Molnau
        I run into this problem all the time when I receive a file that needs to be reformatted or cleaned up. If it is a one-time shot, then an editor can be used but
        Message 3 of 4 , Mar 15, 2009
        • 0 Attachment
          I run into this problem all the time when I receive a file that needs
          to be reformatted or cleaned up. If it is a one-time shot, then an
          editor can be used but not if the file to be edited shows up with any
          regularity. Using an editor is sometimes an option but if it is a
          repetitive task then some sort of program is called for. If the
          editor is programable (perhaps with applescript), then all the edits
          can be made automatic (after the first one). If an editor is not
          used, then a program written in any language (basic, applescript,
          etc) is called for.

          Myron
        • basicbasically
          Thanks for the replay, Jeff. This is the first chance I ve had to get back here and see responses, so forgive me for that. I do use TextWrangler, and did
          Message 4 of 4 , Apr 5, 2009
          • 0 Attachment
            Thanks for the replay, Jeff. This is the first chance I've had to get back here and see responses, so forgive me for that.

            I do use TextWrangler, and did attempt to manipulate the file into usability with it. But in the end, I used MS Word, because I just needed something quick and I didn't have the time to learn TW's specifics in time to get the job done.

            But as Myron said, this is a file that shows up quarterly, so it really calls for a 'loader' program to parse thru the idiosyncracies and spit out a simple tab-delimited file.

            Your snippet will get me started, so I thank you for that.

            - Kevin
          Your message has been successfully submitted and would be delivered to recipients shortly.