Easy way to mock up Position based Flat File
-
I am trying to mock up data for below positioning:
- Header
a. File creation date = position 9-16
b. File Control Number = position 17-24 - 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 - 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 202005070000114320000001I 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
- Header
-
@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. UnlessMBD
is part of your date format. -
My first thought was that the new multiple vertical edge feature might help, but with that amount of columns I’m not so sure.
-
Can you please share some insight on Multiple verticle edge?
-
@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
-
@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:
- 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.
- Create a new script, and get it as good as you can
- 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.
- All example text should be marked as plain text using the
For the script algorithm itself, here are a few top-level ideas I had:
-
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 cursoreditor.getCurrentPosition()
will return the position number of the cursoreditor.positionFromLine(line)
will return the position number of the first character of the given lineeditor.setSelection(startPos,endPos)
will change which text is selectededitor.search()
and related: regex-based searching
- Algorithm:
- 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 - Subtract the start-of-line position from the current position to determine which field you are in
- Determine the startPos and endPos for the next or previous field based on which field you are in, and move the selection
- Use the current line to figure out whether you are on header/detail/trailer line (maybe a variant of
- PythonScript: some useful API calls for the algorithm below
-
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
-
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
-
@Sonali-Dixit said:
Can you please share some insight on Multiple verticle edge?
-
@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.
-
@PeterJones Thank you Peter, this will be a great start for me again going back to scripts :)
-
@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