Firstly, readLines
is a perfectly cromulent way to read your HH line by line, but it will need some extra processing to be useful, while you can get them from your database ready to use, along with as every stat from every hand ever.
I couldn’t find any old scripts, but I do still have my database, so I had a quick look to see what I could remember… which is not much.
I used PT4, which uses PosgreSQL, I don’t know which db HEM2 uses, but connecting to the database will likely be different for you.
There are several packages available for working with databases, but here are the ones I used for this.
library(DBI)
library(RPostgreSQL)
library(dbplyr)
To connect to my database:
con <- dbConnect(
drv = 'PostgreSQL',
dbname = 'PT4 DB',
user = '*****',
password = '*****')
table_list <- dbListTables(con)
I have 38 tables I can extract.
table_list
# [1] "cash_hand_summary"
# [2] "cash_hand_player_statistics"
# [3] "cash_hand_player_combinations"
# [4] "cash_hand_histories"
# [5] "cash_limit"
# [6] "cash_table"
# [7] "cash_table_session_summary"
# [8] "tourney_hand_summary"
# [9] "tourney_hand_player_combinations"
# [10] "tourney_hand_player_statistics"
# [11] "tourney_blinds"
# [12] "tourney_summary"
# [13] "tourney_results"
# [14] "tourney_table"
# [15] "tourney_hand_histories"
# [16] "tourney_table_type"
# [17] "lookup_tourney_type"
# [18] "lookup_hand_groups"
# [19] "lookup_hand_ranks"
# [20] "lookup_hole_cards"
# [21] "lookup_suits_omaha"
# [22] "lookup_positions"
# [23] "lookup_sites"
# [24] "lookup_actions"
# [25] "lookup_tags"
# [26] "tags"
# [27] "notes"
# [28] "notes_auto"
# [29] "player"
# [30] "settings"
# [31] "cash_cache"
# [32] "cash_custom_cache"
# [33] "tourney_cache"
# [34] "tourney_custom_cache"
# [35] "live_tourney_player"
# [36] "live_cash_table"
# [37] "live_cash_player"
# [38] "live_tourney_table"
You can select and join these in any way you like using the dbplyr
package.
WARNING: Be ready for some serious mind melting overload 

Some of these are simple lookup tables others, depending on how many hands you have played, are tables of millions of rows x hundreds of columns!
To get individual tables you would do something like:
all_player_stats <- tbl(con, 'cash_hand_player_statistics')
Remember to disconnect from your database
dbDisconnect(con)
Its pretty cool what you can do - I remember having a script that could read the HH and update HUD stats in (slightly lagged) real time, when my HUD wasn't working.
Unfortunately, that's all I've got right now. If you go down this route, I'd be interested to hear how you get on