Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

Copy paste prompt taker outer thing

TeshaTesha Posts: 2,881Member @@ - Legendary Achaean
I want something I can copy/paste a log into, and it'll just remove the prompts, and then I can paste the log.

Maybe for html too.

I imagine other people would be interested in a copy paste prompt taker outer thing. Maybe they'd be willing to chip in with incentive for some genius coder?!

Would anyone like to make a copy paste prompt taker outer thing, or be willing to share one?

 i'm a rebel

Comments

  • AustereAustere TennesseePosts: 2,201Member @@ - Legendary Achaean
    edited September 2015
    I use notepad's replace function and just leave the second box empty. Works good unless your prompt changes a lot. .
    Jadys
  • TeshaTesha Posts: 2,881Member @@ - Legendary Achaean
    I have timestamps on my prompt. :(

     i'm a rebel

  • LyrLyr Posts: 419Member ✭✭✭✭ - Eminent
    I could probably cook one up really quick.
  • AesiAesi Posts: 1,222Member @ - Epic Achaean
    you just need some crafty regex ninja skills!
  • TeshaTesha Posts: 2,881Member @@ - Legendary Achaean
    Kei said sublime text could do it, but that sounds like weird ninja stuff. That might be able to work!

    Does anyone have any ideas for cleaning up other parts of logs? Like inventory, or the line where you sent the command? Like this:


    5258h (100%), 3979m (85%), 100%w exEcdbkrh-  20:05:53.28   say *curiously So what is Light, exactly? What does this "guiding force" actually mean?
    You say curiously in a mellifluous voice, "So what is Light, exactly? What does this 
    "guiding force" actually mean?"

    The bolded would be things I would want removed. I'd also like the line break between this and "guiding removed, too. I imagine I'd probably have to do that manually?

     i'm a rebel

  • TeshaTesha Posts: 2,881Member @@ - Legendary Achaean
    Kei also said the line break could be removed, which is just plain sorcery to me. If she doesn't post how to do it here, I'll just post an update later for anyone else who wants magical log cleaning stuff.

     i'm a rebel

    Jadys
  • LyrLyr Posts: 419Member ✭✭✭✭ - Eminent
    edited September 2015
    Try

    https://stephen.lester.io/projects/achaea/log-cleaner.html

    & let me know if something's broken, and I'll try to fix it. It worked in a short example I did.

    (This just takes out prompts based on the first line. Taking out inventory, qw, etc isn't that much more difficult necessarily but it's more prone to error depending.)
    PraxidesDochitha
  • TaelTael Posts: 1,197Member @ - Epic Achaean
    edited September 2015
    You just need regex!

    Any even half-decent text-editor will have regex search and replace.

    If you wanted to clean out your prompt lines like this:

    "5258h (100%), 3979m (85%), 100%w exEcdbkrh-  20:05:53.28   "

    You would want this:
    ^\d+h \(\d+%\), \d+m \(\d+%\), \d+%w \w+- \d+:\d+:\d+\.\d+\s+

    So it matches lines with:
    ^: beginning of line
    \d: a number
    +: one or more of the last thing (in this case one or more numbers)
    h : the letter h and a space
    \(: an open paren (the \ means to ignore the special thing an open paren normally in regex)
    \d+: one or more numbers
    %\), : a percent sign, a close paren, a comma, and a space
    \d+: one or more numbers
    m \(: the letter m, a space, and an open paren
    \d+: one or more numbers
    %\), : a percent sign, a close paren, a comma, and a space
    \d+: one or more numbers
    %w : a percent sign, the letter w, and a space
    \w+: one or more alphanumeric characters (to match the string of letters)
    - : a dash and a space
    \d+: one or more numbers
    :: a colon
    \d+: one or more numbers
    :: a colon
    \d+: one or more numbers
    \.: a period (again, a period means something special in regex, so we put a \ in front of it to mean "just a period, nothign special)
    \d+: one or more numbers
    \s+: one or more spaces

    You could also be lazier if every prompt comes with a timestamp:
    ^.+ \d+:\d+:\d+\.\d+\s+

    So it matches lines with:
    ^: beginning of line
    .: any character
    +: one or more of the last thing (in this case one or more characters)
    a space
    then the same stuff as above for the timestamp

    That'll just grab a timestamp and all of the stuff on every line that comes before the timestamp, so you can just replace it with nothing.
    Rohai
  • LyrLyr Posts: 419Member ✭✭✭✭ - Eminent
    You'll also need to add a ^ to the beginning if you have things like svo appending things to it. And +, ., commas, (, ), $, are all special characters people may use.
  • LyrLyr Posts: 419Member ✭✭✭✭ - Eminent
    It's also a bit harder in a text editor, since you want to delete whole lines that match those, not just what was matched. If that script I threw together doesn't work, just let me know. You can even download the HTML file and run it locally.
  • TaelTael Posts: 1,197Member @ - Epic Achaean
    edited September 2015
    Lyr said:
    It's also a bit harder in a text editor, since you want to delete whole lines that match those, not just what was matched. If that script I threw together doesn't work, just let me know. You can even download the HTML file and run it locally.
    It's still pretty easy if you want to delete the whole lines.

    Just slap a .*$ onto the end of the pattern (zero or more (*) of any characters (.) and the end of the line ($)).

    If you want to be really lazy you could just throw a random symbol into the beginning of your custom prompt and delete all the lines with that symbol in it. Like put % at the beginning of your prompt then search and replace lines with:

    ^%.*$

    Since only your prompt will ever start with %, you can safely discard every line.
  • EldEld Posts: 3,946Member @@ - Legendary Achaean
    sed "/^[0-9]\+h/d" inputfile > outputfile
  • SenaSena Posts: 3,938Member @@ - Legendary Achaean
    I use LogEdit. You can set up a series of filters to replace/remove whatever you want, and enable/disable them as needed. Once the filters are set up (I don't have them right now because I haven't used it since switching computers), I can pretty much entirely clean a huge log (removing channels, inventory, prompts, who/qw, extra blank lines, etc.) in a couple minutes.
    EldTael
  • TrevizeTrevize Posts: 1,517Member @ - Epic Achaean
    Current scripts: GoldTracker 1.2, mData 1.1
    Site: https://github.com/trevize-achaea/scripts/releases
    Thread: http://forums.achaea.com/discussion/4064/trevizes-scripts
    Latest update: 9/26/2015 better character name handling in GoldTracker, separation of script and settings, addition of gold report and gold distribute aliases.
    LorielanPraxidesTael
  • TaelTael Posts: 1,197Member @ - Epic Achaean
    edited September 2015
    Eld said:
    sed "/^[0-9]\+h/d" inputfile > outputfile
    Whether that even works will depend on your sed (it might work, it might require you to drop the \ before the + and use either an -r or an -E switch, or it might be impossible), since the + quantifier isn't a thing in basic regular expressions.
    Eld
  • AmranuAmranu Posts: 725Member ✭✭✭✭ - Eminent
    To be fair, that should work on any modern linux desktop.
  • EldEld Posts: 3,946Member @@ - Legendary Achaean
    Tael said:
    Eld said:
    sed "/^[0-9]\+h/d" inputfile > outputfile
    Whether that even works will depend on your sed (it might work, it might require you to drop the \ before the + and use either an -r or an -E switch, or it might be impossible), since the + quantifier isn't a thing in basic regular expressions.
    Ah, right, I'd forgotten that + and ? weren't included in the POSIX basic RE standard. So 
    sed "/^[0-9]\{1,\}h/d" inputfile > outputfile
    or 
    sed -E "/^[0-9]+h/d" inputfile > outputfile,
    if your implementation supports EREs (I suspect you'd have a hard time finding one that didn't, but who knows).

    Amranu said:
    To be fair, that should work on any modern linux desktop.
    Yes, but probably not in most BSDs, and by extension MacOS.
Sign In to Comment.