0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PowerShell で固定長を CSV に変換

Posted at

自分のためにメモ

固定長を CSV に変換

$fileContent = Get-Content -Path 'C:\workspaces\test\FixedLength.txt'
$csvData | Set-Content -Path 'C:\workspaces\test\output.csv'
$csvData = $fileContent | ForEach-Object {
    $field1 = $_.Substring(0, 10).Trim()
    $field2 = $_.Substring(10, 10).Trim()
    $field3 = $_.Substring(20, 10).Trim()
    "$field1,$field2,$field3"
}
$csvData | Set-Content -Path 'C:\workspaces\test\output.csv'

サンプル

固定長
1234567890アイウエオカキクケコAAAAAAAAAA
1234567890サシスセソタチツテトAAAAAAAAAA
1234567890ナニヌネノハヒフヘホAAAAAAAAAA

image.png

image.png

以上です~

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?