![]() |
find some word in text list file and a bit change to them - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: find some word in text list file and a bit change to them (/thread-37569.html) |
find some word in text list file and a bit change to them - RolanRoll - Jun-26-2022 hi I need to find some word in my text list file for example V_20220412 in S1A_IW_SLC__1SDV_20220412T022912_20220412T022940_042734_05197D_3860 then i want to omit " _" so then , it is like this: V20220412 and then i want to get one day before this date : V20220411 after doing these steps for all rows in text list file ,I want to save them in another text file like this: V20220411 V20220318 V20220222 V20220128 V20220105 RE: find some word in text list file and a bit change to them - ibreeden - Jun-26-2022 Use "re" (regular expression) to find the desired string. Use "datetime" to do date arithmetic. Show us your program, and we will help you. RE: find some word in text list file and a bit change to them - BashBedlam - Jun-26-2022 Are you searching for exactly V_20220412 or do you need every occurrence of an eight character sequence that begins withV_ or something else?
RE: find some word in text list file and a bit change to them - RolanRoll - Jun-27-2022 hi first of all i appreciate your help (you and ibreeden) and as you can see in my file names in text list file (below) the date repeated 2 times in every file names (in fore example text list file) but with different times (T= time) i need just date with letter V before because i need the text file that you named it before : "pattern_list.txt" ( your previous code for solving my previous post ) in https://python-forum.io/thread-37560.html so i know you understand what i exactly need (good job) .i have tried to say my problem in two parts(2 posts) because i say these 2 posts in one question , many times ago and i cannot get answer of any body. S1A_IW_SLC__1SDV_20220412T022912_20220412T022940_042734_05197D_3860 S1A_IW_SLC__1SDV_20220223T022912_20220223T022940_042034_0501CA_70EF so for every rows in my text list file (or every file name) , i need to find just one repeated date joined with V and then subtract one day fore all of them (so it should be formatted as date ): V20220411 V20220222 |