Community
    • Login

    Easy way to mock up Position based Flat File

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    12 Posts 3 Posters 5.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Sonali DixitS
      Sonali Dixit
      last edited by

      Hello, I am trying to mock up position based Flat files after long time. I know there used to be an easy way to mock the data without having to worry about positioning and later convert it back. Does any one know the trick?

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by

        You might want to read this FAQ, then come back here and reply with more details for what you’re trying to do.

        1 Reply Last reply Reply Quote 1
        • Sonali DixitS
          Sonali Dixit
          last edited by

          I am trying to mock up data for below positioning:

          1. Header
            a. File creation date = position 9-16
            b. File Control Number = position 17-24
          2. Detail
            a. MBI = position 9-20
            b. Beneficiary’s date of birth = position 30-37
            c. Beneficiary’s gender code = position 38
            d. Detail record sequence number = position 39-45
            e. If you want to fail the record change on or both;
            i. Processed flag = N = position 46
            ii. Beneficiary match flag = N = position 47
            f. Sending entity = position 241-248
            g. File control number = position 249-257 (from Header position 14-24)
            h. File creation date = position 258-265
            i. Beneficiary’s retrieved date of birth = position 624-631
            j. Beneficiary’s retrieved gender code = position 632
            k. Last name = position 633-672
            l. First name = position 673-702
            m. Current State code = position 704-705
            n. Current county code = position 706-708
            o. Active MBI = position 1556-1566
          3. Trailer
            a. File Creation date = position 17-24
            b. File control number = position 25-33
            c. Record count = position 34-40

          CMSBEQRHMBD 20200520000010402
          DTLDTL015D14HH1AA12 1952020310016575YY20140101 20140301 1 H0002 00001040220200520201607012019010120191231110020200101202012311100 195202031LEE1 CIN1 21010 H111120190101Y 000148N 123 HAPPY HWY ARAOLD MD21011 20100601123 HAPPY HWY ARNOLD MD21012 20100601 BBH111120190101 Y00148N 5D14HH1AA12201812052019020120190401
          CMSBEQRTMBD 202005070000114320000001

          I know I can go to each position and change my data, I am trying to find an easier way so I can work on multiple data in an easy way

          PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Sonali Dixit
            last edited by PeterJones

            @Sonali-Dixit said in Easy way to mock up Position based Flat File:

            I know I can go to each position and change my data, I am trying to find an easier way so I can work on multiple data in an easy way

            Looks like this can just barely be considered a text file. To me, it looks more like a data file that happens to only use ASCII characters. Notepad++ isn’t really set up for easily accessing the individual fields in your data structure.

            One could write a plugin (or use the PythonScript or LuaScript plugin to write a script) which could help you automate moving between the fields. But that would be a lot of effort on your part, especially if you don’t know how to program.

            edit: PS: your spec doesn’t match your example. In the header line you supplied, CMSBEQRHMBD 20200520000010402, the date doesn’t start until the 13th character you showed, not the 9th. Unless MBD is part of your date format.

            Sonali DixitS 1 Reply Last reply Reply Quote 3
            • Alan KilbornA
              Alan Kilborn @Sonali Dixit
              last edited by

              @Sonali-Dixit

              My first thought was that the new multiple vertical edge feature might help, but with that amount of columns I’m not so sure.

              1 Reply Last reply Reply Quote 3
              • Sonali DixitS
                Sonali Dixit
                last edited by

                Can you please share some insight on Multiple verticle edge?

                1 Reply Last reply Reply Quote 0
                • Sonali DixitS
                  Sonali Dixit @PeterJones
                  last edited by Sonali Dixit

                  @PeterJones Thank you Peter, I was just giving this as an example on what I am trying to do here, I might have picked the wrong file. Yeah, it’s been long time not programming, but I can still try to write a script, I know it will take time. Let me know if someone can help with scripts

                  PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @Sonali Dixit
                    last edited by PeterJones

                    @Sonali-Dixit said in Easy way to mock up Position based Flat File:

                    Yeah, it’s been long time not programming, but I can still try to write a script, I know it will take time. Let me know if someone can help with scripts

                    If you want to go the script route:

                    1. Use Plugins > Plugins Admin to install PythonScript or LuaScript (depending on whether you think Python or Lua will be an easier language for your script); it might even be doable in JS using the jN Notepad++ Plugin.
                    2. Create a new script, and get it as good as you can
                    3. If you have questions, show us what you’ve tried so far, and ask your questions, and we can help you through it.
                      • All example text should be marked as plain text using the </> toolbar button or using manual Markdown syntax.

                    For the script algorithm itself, here are a few top-level ideas I had:

                    1. Just have the script step to the next appropriate field on a given keystroke; you would then use the editor API for changing for finding out your current position and then moving the selection to the next field.

                      • PythonScript: some useful API calls for the algorithm below
                        • Plugins > PythonScript > Context Help is your friend! Type one of the following API calls into a PythonScript file, highlight it, and then use Context Help entry to take you to the documentation for that method
                        • editor.getCurLine() will return the line number (first line is 0) of the cursor
                        • editor.getCurrentPosition() will return the position number of the cursor
                        • editor.positionFromLine(line) will return the position number of the first character of the given line
                        • editor.setSelection(startPos,endPos) will change which text is selected
                        • editor.search() and related: regex-based searching
                      • Algorithm:
                        1. Use the current line to figure out whether you are on header/detail/trailer line (maybe a variant of line % 3 to get line-number modulo 3, if the file is perfectly h/d/t trios of lines), or maybe use regex to find the header line of the line you’re starting in
                        2. Subtract the start-of-line position from the current position to determine which field you are in
                        3. Determine the startPos and endPos for the next or previous field based on which field you are in, and move the selection
                    2. build up a dialog box (I think some of @Alan-Kilborn’s and/or @Ekopalypse’s example PythonScript code will show how to build a dialog box in PythonScript – one of them can point you to an example if you want to go this route). Use dialog box controls to help you navigate forward/backward a field or a whole record. This uses new GUI elements compared to #1, but the Notepad+±specific API calls will be similar to what’s described in #1

                    3. build a dockable window; the most user friendly, but I don’t know of examples in PythonScript to build a dockable window, so I don’t know how easy/hard that is to implement – it would be similar to #2, except for the docking behavior

                    Alan KilbornA Sonali DixitS 2 Replies Last reply Reply Quote 1
                    • Alan KilbornA
                      Alan Kilborn @Sonali Dixit
                      last edited by

                      @Sonali-Dixit said:

                      Can you please share some insight on Multiple verticle edge?

                      90f98103-ad43-42f6-9911-aa5867ecf016-image.png

                      1 Reply Last reply Reply Quote 2
                      • Alan KilbornA
                        Alan Kilborn @PeterJones
                        last edited by

                        @PeterJones said in Easy way to mock up Position based Flat File:

                        build up a dialog box (I think some of @Alan-Kilborn’s and/or @Ekopalypse’s example PythonScript code will show how to build a dialog box in PythonScript – one of them can point you to an example if you want to go this route).

                        Ha! My dialog boxes are cheezy, but easy!
                        @Ekopalypse 's are harder to do but much nicer.

                        I “stole” my method from HERE; at least that is the one I have recorded in my notes that I reference whenever I’m about to make something new with a “cheezy” UI. There’s a pic of it as well as code in that thread.

                        Sonali DixitS 1 Reply Last reply Reply Quote 2
                        • Sonali DixitS
                          Sonali Dixit @PeterJones
                          last edited by

                          @PeterJones Thank you Peter, this will be a great start for me again going back to scripts :)

                          1 Reply Last reply Reply Quote 0
                          • Sonali DixitS
                            Sonali Dixit @Alan Kilborn
                            last edited by

                            @Alan-Kilborn Thank you Alan, this looks lot easier to work with. but it seems like I need to update my Notepad++ I have older version.

                            Hey by the way, I found one more link that might help, just sharing if any one else can use it. https://www.convertcsv.com/csv-to-flat-file.htm

                            1 Reply Last reply Reply Quote 1
                            • First post
                              Last post
                            The Community of users of the Notepad++ text editor.
                            Powered by NodeBB | Contributors