Find string of text and copy that line twice underneath



  • Good afternoon,

    Every month I find myself manually coding data for the payroll.
    Needless to say that it is daunting and subject to errors.
    I’m not familiar with coding and pretty new to Notepad++
    So here is a cry for help: Can somebody help me on the below?

    I search and bookmark all lines that contain the date of Fridays in February (05, 12, 19 & 26.02.2021) in combination with code (0065 or 0050) and 0800.
    Ex. KLX103025350300569001 05/02/2021 0065 0800
    I need to copy these lines twice underneath it. And replace the date with the one of Saturday and Sunday and change the 0800 hours into 0000.

    Ex. KLX103025350300569001 05/02/2021 0065 0800
    KLX103025350300569001 06/02/2021 0065 0000
    KLX103025350300569001 07/02/2021 0065 0000

    Ex. 2 KLX103025350301979001 12/02/2021 0050 0800
    KLX103025350301979001 13/02/2021 0050 0000
    KLX103025350301979001 14/02/2021 0050 0000

    If Notepad is not the right answer to my question would you have suggestions into which other programs I could look?

    Thanks in advance!
    Saar

    Sample Data:
    KLX103025350300569001 01/02/2021 0065 0800
    KLX103025350300569001 02/02/2021 0065 0800
    KLX103025350300569001 03/02/2021 0065 0800
    KLX103025350300569001 04/02/2021 0065 0800
    KLX103025350300569001 05/02/2021 0065 0800
    KLX103025350300569001 08/02/2021 0065 0800
    KLX103025350300569001 09/02/2021 0065 0800
    KLX103025350300569001 10/02/2021 0065 0800
    KLX103025350300569001 11/02/2021 0065 0800
    KLX103025350300569001 12/02/2021 0065 0800
    KLX103025350300569001 15/02/2021 0065 0800
    KLX103025350300569001 16/02/2021 0065 0800
    KLX103025350300569001 17/02/2021 0065 0800
    KLX103025350300569001 18/02/2021 0065 0800
    KLX103025350300569001 19/02/2021 0065 0800
    KLX103025350300569001 22/02/2021 0065 0800
    KLX103025350300569001 23/02/2021 0065 0800
    KLX103025350300569001 24/02/2021 0065 0800
    KLX103025350300569001 25/02/2021 0065 0800
    KLX103025350300569001 26/02/2021 0065 0800
    KLX103025350300569001 01/03/2021 0065 0800
    KLX103025350300569001 02/03/2021 0065 0800
    KLX103025350300569001 03/03/2021 0065 0800
    KLX103025350300569001 04/03/2021 0065 0800
    KLX103025350300569001 05/03/2021 0065 0800
    KLX103025350300313001 22/03/2021 2355 0800
    KLX103025350300631001 10/02/2021 2355 0800
    KLX103025350300631001 15/02/2021 2355 0800
    KLX103025350300631001 16/02/2021 2355 0800
    KLX103025350300631001 17/02/2021 2355 0800

    KLX103025350300456001 02/03/2021 0050 0800
    KLX103025350300456001 03/03/2021 0050 0800
    KLX103025350300456001 04/03/2021 0050 0800
    KLX103025350300456001 05/03/2021 0050 0800
    KLX103025350300456001 08/03/2021 0050 0800
    KLX103025350300456001 09/03/2021 0050 0800
    KLX103025350300456001 10/03/2021 0050 0800
    KLX103025350300456001 11/03/2021 0050 0800
    KLX103025350300456001 12/03/2021 0050 0800
    KLX103025350301691001 09/02/2021 0232 0800
    KLX103025350301691001 19/02/2021 0136 0800
    KLX103025350301691001 22/02/2021 0136 0800
    KLX103025350301691001 01/03/2021 0050 0800
    KLX103025350301691001 02/03/2021 0050 0800
    KLX103025350301691001 03/03/2021 0050 0800
    KLX103025350301691001 08/03/2021 0136 0800
    KLX103025350301691001 09/03/2021 0136 0800



  • @Saar-De-Longie ,

    The issue with your problem statement is that Notepad++ in general, and the search and replace (aka “regular expression” or “regex”) engine in particular, is unaware of dates, and knowing which days are a Friday (and thus computing the Saturday and Sunday) are way outside of the realm of things you should try to do with a regular expression.

    If I were solving this, I would either write a program in my favorite programming language (I’d use Perl, because that’s what I’m familiar with). Or I might open the text file a a character-separated-value (CSV) file in Excel, and then write a VBA macro to look for Fridays and add lines for the Saturday and Sunday after each Friday found. Either of those techniques would involve learning the appropriate language and asking questions in forums dedicated to the programming language you chose.

    But really, the right way of fixing this is to approach whoever is in charge of generating the text report, and ask if they could make an alternate report for you that includes the Saturdays and Sundays in the output report, If they can’t do that, ask if they can write a converter script to transform from their report to the format you want, or if they know of someone else at your workplace who could (either in their group, or another support group). There’s generally someone in the area – whether they work directly with the database, or are in IT or related group, who knows enough coding to make a quick script to do it. (OTOH, if you were hired with the expectation that you knew how to do that sort of thing… sorry, you’re probably going to have to learn a programming or scripting language yourself… and this forum isn’t the right place for learning such things.)



  • @PeterJones said in Find string of text and copy that line twice underneath:

    Or I might open the text file a a character-separated-value

    I meant, “Or I might open the text file as a character-separated-value”. Sorry.



  • Hi Peter,

    Thanks a lot for your input! Very much appreciated.
    I know now where to go to find a solution.
    Up to the company for which I’m temping right now, to talk to their provider.
    PS I was not hired for the job to develop coding, but it would make my life a lot easier :)

    Kind regards,
    Saar


Log in to reply