How to read a txt file to sort out the string then output to a folder with some txt files
Posted: 26 Feb 2024 10:53
Hi all,
I have a file as attached as below. The purpose is to make it automatically (programmatically) to be ready for the tools.
Here is the original txt file as below: (let's name as source.txt)
-------------------------------------------------------
Schemes_to_Sign_for_852046
Tetra terminal:
From
\T503-08667-0106\Application_Signing\Signed_Schemes\MockupSigned_T3
500122010100.S3S.mockup
500199010200.S3S.mockup
\T503-08667-0109\Application_Signing\Signed_Schemes\MockupSigned_T3
500072010400.S3S.mockup
500083010300.S3S.mockup
500099010300.S3S.mockup
\T503-08939-0102\Application_Signing\Signed_Schemes\MockupSigned_T3
500278010400.S3S.mockup
------------------------------------------------------------
The expected output result is as below:
It will create a folder name as 852046 based upon the last 6 digits string of the first line from source.txt
Under this folder there will be some files, in this cases, will be three files, one is T503-08667-0108.txt, T503-08667-0109.txt, and T503-08939-0102.txt
For each file list fist 6 digits of the scheme under this file
Take an example from above
So for T503-08667-0108.txt, it should list these two strings based upon the info provided from source.txt as below:
500122
500199
T503-08667-0109.txt, it should list these three strings based upon the info provided from source.txt as below:
500072
500083
500099
T503-08939-0102 it should list these one string based upon the info provided from source.txt as below:
500278
I have a file as attached as below. The purpose is to make it automatically (programmatically) to be ready for the tools.
Here is the original txt file as below: (let's name as source.txt)
-------------------------------------------------------
Schemes_to_Sign_for_852046
Tetra terminal:
From
\T503-08667-0106\Application_Signing\Signed_Schemes\MockupSigned_T3
500122010100.S3S.mockup
500199010200.S3S.mockup
\T503-08667-0109\Application_Signing\Signed_Schemes\MockupSigned_T3
500072010400.S3S.mockup
500083010300.S3S.mockup
500099010300.S3S.mockup
\T503-08939-0102\Application_Signing\Signed_Schemes\MockupSigned_T3
500278010400.S3S.mockup
------------------------------------------------------------
The expected output result is as below:
It will create a folder name as 852046 based upon the last 6 digits string of the first line from source.txt
Under this folder there will be some files, in this cases, will be three files, one is T503-08667-0108.txt, T503-08667-0109.txt, and T503-08939-0102.txt
For each file list fist 6 digits of the scheme under this file
Take an example from above
So for T503-08667-0108.txt, it should list these two strings based upon the info provided from source.txt as below:
500122
500199
T503-08667-0109.txt, it should list these three strings based upon the info provided from source.txt as below:
500072
500083
500099
T503-08939-0102 it should list these one string based upon the info provided from source.txt as below:
500278