Automatic list making? - list

There are bunch of pages of a same website.
the first one is
http://www.theeuropeanlibrary.org/tel4/search?classification-cerif=H000&iyear=[2000%20TO%202010]&offset=20
the next one is almost like the firt,but differs in the number at the last,and is 2 times 20 which is 40.so,the number for the 2000th address would be 2000 times 20.Now hw can i make a txt file containing the 2000 addresses which made out of the first one by
the rule i said above?
I don't have any programming experience,but
i have notepad ++ installed.

Copy the constant string in the first line of the new file in Notepad++
http://www.theeuropeanlibrary.org/tel4/search?classification-cerif=H000&iyear=[2000%20TO%202010]&offset=
duplicate this line (Ctrl+D) as many times you want
position the cursor at the end of the first line
Alt+Shift+Arrow down until the last line
enter the column mode Alt+C
in the popup window, enter the first number (i.e. 20) and the incremant (i.e. 20)
click OK
That's it.

Related

Delete every other line in Visual Studio Code regardless of content

A colleague has inserted duplicates for ~1200 entries into our database. They have sent me a text file containing both the originals and copies in alternating lines of CSV text. I've opened that up in VS Code with the goal of converting the lines representing duplicates into DELETE statements targeting our database. No line is truly identical to another—every two is a pair in which the data is the same other than the row ID.
I have found Stack Overflow entries for removing every other line when the line is empty, or when every other line is an exact copy of the previous line. I have not found an entry this scenario in which the lines have a difference. E.g. I tried using (.*)\n\1 w/ $1\n from another SO entry, which seems to target truly duplicate lines.
So how do I use VS Code to delete every other line regardless of content?
You can achieve this using Replace-All UI in regex mode.
Press command-F or control-F
Expand the arrow on the left of the Find display
Press the ".*" so that it's highlighted
Enter this for Find (top text field in the Find UI): (.*\n)(.*)\n (basically select two lines but save the contents of the first line in the regex system)
Enter this for Replace (following text field in the find UI): $1 (take the line saved from the Find regex and re-insert it)
Hit the Replace All button
Here's a similar SO question

How to display m[,n] lines around current line in pdb?

The Python 2.7 debugger pdb allows to display lines o to p with l [o[,p]], but one has to figure out which line the debugger stand on and then substract and add. Is there a way to display an m lines before and n lines after the current line without arithmetics?
As far as I know, no. The l(ist) command will display 11 lines around the current line, but you can't display m lines before and n after the current line.
https://docs.python.org/2/library/pdb.html
l(ist) [first[, last]]
List source code for the current file. Without arguments, list 11 lines around the current line or continue the previous listing. With one argument, list 11 lines around at that line. With two arguments, list the given range; if the second argument is less than the first, it is interpreted as a count.

Add trailing zeroes to line in notepad++

I have a file containing (hundreds) of blocks of numbers like below;
This one is fine (16x20, correct number of rows and columns)
11111111111111111110
16666616666666661110
16111616111111162610
16111646111663132610
16162616261623132610
16162313261623132610
16162313261623132610
16162313261623132610
16162313261623132610
16162313261623132610
16162313261623132610
16162313261626132610
16166313661116632610
16111111111116132610
16666666666666136610
11111111111111111110
This one needs to be padded with trailing zeroes so it is (16x20)
111111111111111111
166616666666663661
166611111111111661
166666366663661661
113161111111161611
1316166666616161
1616162262616161
11616166112616161
16616166116616161
16616162262616161
16616166266616161
16616111161116161
1661666666666616111
1661666166163366661
1641666166166613661
1111111111111111111
I would like to pad them with zeroes so they are all like the first example. I'm aware of the regular expressions feature in notepad++ but am struggling to get it to work. I appreciate any help given.
You could do it via a macro.
First append a large number of zeroes to the end of each line using a macro.
Caret on the first entry
click record macro
press end
type out 20 zeroes
press down arrow
click stop recording
play the macro until all lines look like this
11111111111111111100000000000000000000000000000000000000000000
16661666666666366100000000000000000000000000000000000000000000
16661111111111166100000000000000000000000000000000000000000000
16666636666366166100000000000000000000000000000000000000000000
11316111111116161100000000000000000000000000000000000000000000
131616666661616100000000000000000000000000000000000000000000
161616226261616100000000000000000000000000000000000000000000
1161616611261616100000000000000000000000000000000000000000000
1661616611661616100000000000000000000000000000000000000000000
1661616226261616100000000000000000000000000000000000000000000
1661616626661616100000000000000000000000000000000000000000000
1661611116111616100000000000000000000000000000000000000000000
166166666666661611100000000000000000000000000000000000000000000
166166616616336666100000000000000000000000000000000000000000000
164166616616661366100000000000000000000000000000000000000000000
111111111111111111100000000000000000000000000000000000000000000
Then...
Caret on first line
click record
press home key
press the right arrow key 20 times
hold shift and press end key
press delete key
press down arrow
click stop recording
play the macro until all lines are processed
You could save the entire process as a single macro so its just a single click in the future.
I can give you a macro solution
go to the beginning of your text
select Macro/Start Recording
press end, press 0 16 times then press Home and down arrow key
select Macro/End Recording
You now have a macro to add sixteen zeros to the end of all lines.
Playback this macro on all lines.
You now have appended zeroes to all lines.
Pressing Alt key and using mouse select the required block(columns) of text you want and paste it into another empty notepad tab
help on column mode editing is there inside notepad ? / help contents menu
Good luck
You can use the plugin ConyEdit to do this.
With ConyEdit running in the background, follow these steps:
use the command line cc.aal 00000000000000000000 to append after lines with twenty zero character.
use the command line cc.gc 1/\d{20}/ to get the first column of regex match.
Looking to do this manualy and not progomaticly ?
Open Findreplace
Copy from the last to rhe first WITHOUT NUMBERS on a line so...
in this example
111111111111111111 <---from here
to here ---> 166616666666663661
166611111111111661
paste that into the fine ( yes your effecticly copying the return wich some applications allow you to manualy input others wont )
then in the replace box, type '0' then your return
Hit that magic replace all :D
This will then add a 0 every time it hits a new line, then add a new... new line....
edit : quickly reviewing another method a second to recover for alternate options :P give me 10
edit 2:
Ah ok somthing like this will work :P just tested it.
use [0-9] in the find replace. so if im looking for 123123123123 ( wich is 12 long ) and i need to buff i up to 20,
Your FIND must be in ()
so..
the find would be
([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] )
and the replace is referd to as \1 no the regex, this was my mistake
\100000000
tested and confirmed !dont forget YOU NEED MATCH ALL on, WRAP off!
And so on for your other numbers, Not sure if you can loop this with macros nd stuff :P but hope it helps more than you have now
two good resources.
http://blog.creativeitp.com/posts-and-articles/editors/understanding-regex-with-notepad/comment-page-1/
http://regexpal.com/
base on OP's comment: you could try an editor called vim/gvim
open your file in vim, then type:
:%s/.*/\=printf("%-20s",getline("."))/|%s/ *$/\=substitute(submatch(0)," ","0","g")/
don't forget pressing <Enter> after the above typing.
then you will see the text has been changed into what you want.
of course vim macro can work as well, however, I feel command better... :)

Search and replace in text file - add a constant to a numbered sequence

I've got a file, actually a .bat file but it could be any text file, with contents I want to update. I want to replace throughout the file the number after some text like this:
%varXX where XX is a number, one or two digits. The numbers go typically from 1 to 35.
Example: %var10 ---> add a known number to add to 10, like 2, result is %var12. I want to choose the number I start doing this at like 10 in this example and I want to choose the number to add to all of these occurrences, up to 35 occurrences. I will also need to, at times, subtract instead of add this number. I'm on a windows computer.
Update - found part solution using VIM:
:%s#%var\(\d\+\)#\='%var' . (submatch(1) + 3)#g
Here in this example, 3 is the amount I'm adding. However, this searches for any numbers following var and adds 3. How do I modify the above command to start at a number I choose?

vim regex : multi-line edit and controlling the cursor position

A text file is formatted like this:
Section 4 Area B Unit 20
stuff i don't need...
stuff i don't need...
45990 - Title of Project that I want to save
line of text I need to keep
line of text I need to keep
2010-11 this line (starting with 2010) is not needed
stuff i don't need
Section 589 Area C Unit 1005
stuff i don't need...
stuff i don't need...
45990 - Title of Project that I want to save
line of text I need to keep
line of text I need to keep
2010-11 this line (starting with 2010) is not needed
stuff i don't need
and these sections repeat by the hundreds. The "stuff i don't need" lines are actually about 30 or so. I need to keep the association of the "Section..." line, "Title..." line and "line of text I need to keep" related to each other. So I was hoping to first destruct the text document down (linewise) to the stuff I need before operating on it further (character-wise). So I wrote this:
g!/\Section\s\d*\sArea\s\h\sUnit\s\d*\n\|^\s\{3}\zs\d*\s-\_.*\ze2010-11/d
After deleting I get the "Section.." line and the "Title..." line, but never the subsequent lines underneath the "Title.." line. Those subsequent lines vary from 4 to 8 lines, but the "2010-11" line is consistent and always what I no longer want.
You can see I tried using zs and ze to select what I do not want deleted. I think the selection is working because if I change the command to "2011-12" then there is no match and the (OR) half of the command does not return a result.
I think the fault might be the cursor position(?), but I'm not sure and my effort to fix that has failed.
Can anyone see my error?
Thanks!
Give this a whirl.
:silent! g/^Section/+ , /^\s\+\d\+ -/- d
:g/^\s\+2010/ , -/\nSection\|\%$/ d
:g finds every line matching start of the pattern, ! will revert the selection and command will get applied to these lines.
Would something like g/^Section.../normal! j2dd3jd} do?
If not you can use a search for the Title line inside normal!
You may need to enclose it in "exec" but may be much simpler to write a function.
Do you really need to use vim? Seems like job for Perl to me.
There are many ways to do t, I'm sure. I think this sequence of commands should work (ignoring comment lines that begin with double quote):
" global delete of line below 'Section' to line before 'Title'
g/^\s*Section/+1;/Title/-1delete
" global delete from date line to line before 'Section'
g/^\s*\d\d\d\d-\d\d/;/^\s*Section/-1delete
" go to top line of buffer
gg
" delete last chunk, from final date to last line
/^\s*\d\d\d\d-\d\d/;$delete