My goodness, that was hard, without the godly knowledge of u/tirlibibi17 at my disposal! Encountered issues with that Wilson chick who had a whopping 21 charges against her! And there was this dude who was charged 2 separate times!
Edit: the principle for parsing both files is the same:
find a way to group related lines together. In the case of the first file, this is done by adding an index column, then adding a custom column that equals the index when the line contains ______ and null otherwise. Filling down gives you a nice column to group on. In the case of the second file, it's simpler because characters 2-11 are a unique id.
group the related lines together into a table (column all)
duplicate the query and name it Parse1Query (resp. Parse2Query). Now, click on one of the tables in column all and parse that
now, right-click on the step immediately following the drill-down above and click "Extract previous". Call it Parse1SampleTable (resp. Parse2SampleTable)
create a parameter called tbl (resp. tbl2), make it optional, edit the parameter in the advanced editor and replace null with Parse1SampleTable (resp. Parse1SampleTable)
go back to Parse1Query (resp. Parse2Query) and set the first step (Source) to =tbl (resp =tbl2)
right-click Parse1Query (resp. Parse2Query) and select "Create function". Name it Parse1 (resp. Parse2)
go back to the original query and apply the custom function you created to the "all" column
Anyways, this was interesting and fun. As a European, I find it a bit freaky that such information is openly available (very un-GDPR). Are the mugshots also freely available? Are the reports you posted available for download somewhere?
Yes and yes, arrest records are all public. Interestingly some unsavory website owners download and rehost mugshot and arrest info on their own servers. So, if you get your record expunged (effectively erased), your mugshot and crime is still out there and appears in Google searches -- and these websites charge hundreds to have them taken down. Crazy
I've edited my comment to explain how it was done. It's almost all point and click.
Power Query's ability to create functions from queries that update when you update the query is really the game-changer here because it allows you to step through your function for troubleshooting.
Damn, I pulled file two up for a few minutes this morning and already had the 11 digit unique ID idea going but had to leave before I got any further. Great solution.
These records are most likely extracts from an IBM AS/400 or iSeries (Cobol etc...) and were designed for a fixed width (not proportional) font on a 5250 "green screen".
It's half-assed because I have zero knowledge of M and did not even use PowerPivot. It's also half-assed because I did an intermediate query followed by another query, with the final information presented using formulas.
Unfortunately the original post got deleted by reddit bots. Basically the above, but with LAMBDA instead of Power Query. Pretty "simple" all things considered, my custom function bycolsplit (included inside the nested LAMBDA) helps out a ton as the charges are all in row 3 by the time it gets parsed.
The most important part here is REPLACE 128, 107, 42, which inserts my custom delimiter (i call them delimojis) at those specified places, as they are all formatted to have the same spacing.
Index numbers are assigned using SCAN, each "____" assigns a new index number, which then is able to be fed through FILTER inside the nested LAMBDA to be evaluated.
A nested IF is in place to "short-circuit" and not let it further evalute if it deems it invalid, e.g. new page / header / blank (at the very bottom) / etc
Thanks to u/tirlibibi17 for maintaining a copy of the raw files and u/pancak3d for the challenge, even if it's 4 years old.........
Downsides of this approach: doesn't automatically load in the txt file, have to paste raw txt to A1:A247
5
u/sqylogin 755 Nov 04 '18
Here's another half-assed attempt on No. 2.
http://upload.jetsam.org/documents/File%202%20Challenge.xlsx
My goodness, that was hard, without the godly knowledge of u/tirlibibi17 at my disposal! Encountered issues with that Wilson chick who had a whopping 21 charges against her! And there was this dude who was charged 2 separate times!
3
u/tirlibibi17 Nov 04 '18 edited Nov 04 '18
File 1 parsedBoth files parsed + source files paths configurable==> https://github.com/tirlibibi17/r_excel-stuff/tree/master/20181104%20pancak3d%20PQ%20challengeEdit: the principle for parsing both files is the same:
______and null otherwise. Filling down gives you a nice column to group on. In the case of the second file, it's simpler because characters 2-11 are a unique id.=tbl(resp=tbl2)2
u/pancak3d 1189 Nov 03 '18
Tagging a few PQ pros who were looking for a challenge:
u/alittlebigger u/small_trunks u/tirlibibi17
1
u/small_trunks 1638 Nov 03 '18
I'll give you a hint - change your font to Courier New.
2
u/sqylogin 755 Nov 04 '18
Here is my half-assed attempt.
http://upload.jetsam.org/documents/File%201%20Challenge.xlsx
It's half-assed because I have zero knowledge of M and did not even use PowerPivot. It's also half-assed because I did an intermediate query followed by another query, with the final information presented using formulas.
1
u/small_trunks 1638 Nov 03 '18
Tomorrow...
1
u/Keipaws 219 Dec 05 '22 edited Dec 05 '22
Sample file (Office 365 2212)
Unfortunately the original post got deleted by reddit bots. Basically the above, but with LAMBDA instead of Power Query. Pretty "simple" all things considered, my custom function bycolsplit (included inside the nested LAMBDA) helps out a ton as the charges are all in row 3 by the time it gets parsed.
The most important part here is REPLACE 128, 107, 42, which inserts my custom delimiter (i call them delimojis) at those specified places, as they are all formatted to have the same spacing.
Index numbers are assigned using SCAN, each "____" assigns a new index number, which then is able to be fed through FILTER inside the nested LAMBDA to be evaluated.
A nested IF is in place to "short-circuit" and not let it further evalute if it deems it invalid, e.g. new page / header / blank (at the very bottom) / etc
Thanks to u/tirlibibi17 for maintaining a copy of the raw files and u/pancak3d for the challenge, even if it's 4 years old.........
Downsides of this approach: doesn't automatically load in the txt file, have to paste raw txt to A1:A247
1
u/Decronym Dec 05 '22 edited Nov 02 '25
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.
Beep-boop, I am a helper bot. Please do not verify me as a solution.
5 acronyms in this thread; the most compressed thread commented on today has 16 acronyms.
[Thread #20464 for this sub, first seen 5th Dec 2022, 11:12] [FAQ] [Full list] ^[Contact] [Source code]