I have a file in blob storage which contains 5 delimiter(columns). Few line contains more than 5 delimiters. I need to remove the lines which contains more than 5 delimiters from the Azure Blob and store into another blob.
Source blob:
A;B;C;D;E
A;B;C;D;E
A;B;C;D;E;F
A;B;C;D;E
A;B;C;D;E;F;G
A;B;C;D;E
Destination blob should be:
A;B;C;D;E
A;B;C;D;E
A;B;C;D;E
A;B;C;D;E
CodePudding user response:
Something like this perhaps? (not really familiar with blobs..)
$blob = @"
A;B;C;D;E
A;B;C;D;E
A;B;C;D;E;F
A;B;C;D;E
A;B;C;D;E;F;G
A;B;C;D;E
"@
$blob -split '\r?\n' | ForEach-Object {($_ -split ';')[0..4] -join ';'}
I may have misread this question (thanks Mathias) and you want to remove the lines that have more than 5 items.
$blob = @"
A;B;C;D;E
A;B;C;D;E
A;B;C;D;E;F
A;B;C;D;E
A;B;C;D;E;F;G
A;B;C;D;E
"@
$blob -split '\r?\n' | Where-Object { @($_ -split ';').Count -eq 5 }