Tuesday, November 14, 2017

Re: Vim surprisingly slow?

Tim Chase wrote:
> :g/.*name":"\([^"]*\)".*card":"\([^"]*\)".*/let
> s=substitute(getline('.'), '.*stamp":"\(\d\+\)-\(\d\+\)-\(\d\+\).*',
> '\1\2\3','').'.txt'|s//\1,\2/|exec ".w!>>".s
> which works. But for some reason, it is *painfully* slow on my
> machine.

Just do one write.

:v/"creditcard":"[0-9][0-9-]*"/d|%s!,*"\([a-z][a-z]*\)":!;\1=!g|%s,^{;,,|%s/},*$//|%s,\(timestamp="....\)-\(..\)-\(..\)[^"]*,\1\2\3,|%s!$!;echo '"'"$name"'"'",$creditcard" >> $timestamp.csv!|w ! /bin/sh -

That will probably work in ordinary vi, but my copy of nvi was unhappy.
I didn't try to figure out why. But I did prove to myself it works with
slight editing in ed. ("ed is the standard editor.")

v/"creditcard":"[0-9][0-9-]*"/d
1,$s!,*"\([a-z][a-z]*\)":!;\1=!g
1,$s,^{;,,
1,$s/},*$//
1,$s,\(timestamp="....\)-\(..\)-\(..\)[^"]*,\1\2\3,
1,$s!$!;echo '"'"$name"'"'",$creditcard" >> $timestamp.csv!
w data.json.sh
! /bin/sh data.json.sh

The fix for taking hyphens out of the credit card number should be
obvious, I didn't see any requirement to do that there, so I didn't.

I tried to post my solution to the dev.to site, but it wouldn't let me
log in with Firefox (nothing happened when pushing the github button).
I did not even try to login with lynx.

Elijah

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: