just new to powershell. I need an listed report taken from such below txt report. this is only some lines of example. I have more than 10000 lines such kind of this.
PIPELINE REF LINENUMBER_A
BATCH REF XXXA
PIPING SPEC 01B
N.S. LENGTH QTY QTY
BOLT DESCRIPTION (INS) (MM) ITEM CODE FAB EREC
---------------- ---- ------ --------- --- ----
70 STUD BOLTS & 2 HEAVY Hex Nuts 1/2 70 0597461 0 4
B18.2.1/B18.2.2 A320-L7M/A194-7M (S3)
SPUN GLV TO F2329 INCH SIZE
1 31 Mar 2021 Page 1
PIPELINE REF LINENUMBER_B
BATCH REF XXXB
PIPING SPEC 01C
N.S. LENGTH QTY QTY
BOLT DESCRIPTION (INS) (MM) ITEM CODE FAB EREC
---------------- ---- ------ --------- --- ----
90 STUD BOLTS & 2 HEAVY Hex Nuts 5/8 90 7452665 0 16
B18.2.1/B18.2.2 A320-B8M CL2
(S1/S3)/A194-8MA INCH SIZE
210 STUD BOLTS & 3 HH Nuts 1.1/8 210 9989993 0 16
B18.2.1/B18.2.2 A320-B8M CL2
(S1/S3)/A194-8MA INCH SIZE-With a 3rd
nut for tensioning
The result I expected as comma separated is enough as below:
LINENUMBER_A,01B,STUD BOLTS & 2 HEAVY Hex Nuts,1/2,70,0597461,0,4 LINENUMBER_B,01C,STUD BOLTS & 2 HEAVY Hex Nuts,5/8,90,7452665,0,16 LINENUMBER_B,01C,STUD BOLTS & 3 HH Nuts,1.1/8,210,9989993,0,16
I've tried
$p = @("PIPELINE","STUD BOLT")
Get-Content '.\bolt-out.bom' | Select-String -Pattern $p -SimpleMatch | Set-Content test0.txt
but the result is not as expected. anyone can help realy appreciate.
the result is below. I only may need something like concatenate of first array finding + second finding instead of new line number.
PIPELINE REF LINENUMBER_A
90 STUD BOLTS & 2 HEAVY Hex Nuts 5/8 90 7452665 0 16
I would suggest parsing this into a nice CSV file with column headers:
Output on screen should look like:
Regex details of the long regex line: