Azure Powershell 脚本到 remove/filter 行,其中有来自 blob 的额外分隔符
Azure Powershell script to remove/filter line which has extra delimiter from blob
我在 blob 存储中有一个文件,其中包含 5 个分隔符(列)。很少有一行包含超过 5 个分隔符。我需要从 Azure Blob 中删除包含超过 5 个分隔符的行并存储到另一个 blob。
源 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 应该是:
A;B;C;D;E
A;B;C;D;E
A;B;C;D;E
A;B;C;D;E
也许是这样的? (对 blob 不是很熟悉..)
$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 ';'}
我可能看错了这个问题(感谢 Mathias),你想删除 超过 5 个项目的行。
$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 }
我在 blob 存储中有一个文件,其中包含 5 个分隔符(列)。很少有一行包含超过 5 个分隔符。我需要从 Azure Blob 中删除包含超过 5 个分隔符的行并存储到另一个 blob。
源 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 应该是:
A;B;C;D;E
A;B;C;D;E
A;B;C;D;E
A;B;C;D;E
也许是这样的? (对 blob 不是很熟悉..)
$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 ';'}
我可能看错了这个问题(感谢 Mathias),你想删除 超过 5 个项目的行。
$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 }