DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: DONE: Maintain lines in a txt according an aritmetic progression  (Read 12,144 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Maintain lines in a txt according an aritmetic progression

I would like a snack to :
1. Select a txt file
2. Introduce the number of the first line to maintain
3. Introduce the reason of an aritmetic progression .

By example

c:/ejemplo.txt
first line is 2
and the reason is 5

The script will be able of :

Maintain lines 2, 7, 12, 17, etc until the end of the file
Remove the rest of lines

Can you do it ?

Best Regards
Happy New Year

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: DONE: Maintain lines in a txt according an aritmetic progression
« Reply #1 on: December 29, 2013, 03:50 PM »
Seems rather trivial for awk

http://www.thegeekstuff.com/2010/01/8-powerful-awk-built-in-variables-fs-ofs-rs-ors-nr-nf-filename-fnr/

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: DONE: Maintain lines in a txt according an aritmetic progression
« Reply #2 on: December 29, 2013, 06:24 PM »
Running to try
Best Regards
:-*

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: DONE: Maintain lines in a txt according an aritmetic progression
« Reply #3 on: December 29, 2013, 06:43 PM »
grasp grasp grasp cough cough
Win32, i.e. MS-Windows 95 / 98 / ME / NT / 2000 / XP / 2003 / Vista with msvcrt.dll and msvcp60.dll. If msvcrt.dll or msvcp60.dll is not in your Windows/System folder, get them from Microsoft, or (msvcrt.dll only) by installing Internet Explorer 4.0 or higher.
http://gnuwin32.sourceforge.net/packages/gawk.htm

Do you really expect me to develop a new language ?  :o

I am using windows 7. Seems not directly for windows 7 or need additional libraries.
:-[
Is this necessary ?
Don't you have a click click solution ?  :tellme:

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: DONE: Maintain lines in a txt according an aritmetic progression
« Reply #4 on: December 29, 2013, 07:21 PM »
I'm sure you could find a stand-alone nawk.exe someplace.  Also when you say "maintain" I'm not sure what you mean.  If you copy lines to another file do you keep the old file to preserve the line count?  Replace lines in the original file with new line char(s)(empty line?)  Or just take the data and run?  It's kind of vague other than that you want the lines depending on line number in the file.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: DONE: Maintain lines in a txt according an aritmetic progression
« Reply #5 on: December 29, 2013, 07:24 PM »
I'm almost done with this...stay tuned.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: DONE: Maintain lines in a txt according an aritmetic progression
« Reply #7 on: December 29, 2013, 09:44 PM »
Running to try.
I was desperately looking for answers in the web and this is a beloved present.
:-*

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: DONE: Maintain lines in a txt according an aritmetic progression
« Reply #8 on: December 29, 2013, 10:09 PM »
It's workingggggggggggggggggggggg, it's workingggggg !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Now the history :
Some time ago i ask in the forum to obtain the "titulars" from a search.
In the proof I have used the DuckDuckGo search engine.
In my pc and firefox browser the first line is the titular and the items found occupies three lines. So the next is the four. So I put

First Line 1 and every 3 lines after.....

As almost anyone in the forum i am obsessed with the software and how to do things. But obviously i have to found first what I want to do. Express the keys that I need. The language is complex. I use Goldmine - and have an special utility to do - for asking what I need. To remember what i did in the past.

Introduce all these patterns or search chains is boring. Very very boring, but neccesary if you have a lack of memory like me.

Ask the search engine for a method, a phrase, or anything give in the results many new keys useful to find an idea, a target.

And I want Contro Text Tool to do this.

After I use another special tool to introduce the registers in Goldmine

Obviously i take also the keys that usually appear in the google search engine to remember keys.

:Thmbsup: :-*


Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: DONE: Maintain lines in a txt according an aritmetic progression
« Reply #9 on: December 29, 2013, 10:42 PM »
Thanks Skwire. Running and running every day. I am assigning a hotkey to invoke the program often and quickly

Best Regards
Happy New Year

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: DONE: Maintain lines in a txt according an aritmetic progression
« Reply #10 on: December 29, 2013, 10:53 PM »
Depending on the search engine the groups of keys appear in one way or another.
I am using also PSPad to assemble little details if all don't come in the copy-paste operation like I would.....


Wonderful
;D

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: DONE: Maintain lines in a txt according an aritmetic progression
« Reply #11 on: December 30, 2013, 12:38 AM »
Thanks Skwire. Running and running every day. I am assigning a hotkey to invoke the program often and quickly

You're welcome.  I'm glad it's working for you.  =]  I'll move this to the Finished section.

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,947
Re: DONE: Maintain lines in a txt according an aritmetic progression
« Reply #12 on: December 30, 2013, 03:18 AM »

Original address: https://www.donationcoder.com/forum/index.php?topic=36898.0