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?

テキストファイルを読みだして改行が何文字目で入っているかの情報を出力するPGM

0
Posted at

テキストファイルを読みだして改行が何文字目で入っているかの情報を出力するPGM
をpowershellで作成しました

改行情報は(文字数1, 文字数2, ...)のように、次に来る改行までの文字数がいくつあるか
という形式で出力されます

プログラム内容

$arr = Get-Content "C:\読みだしテキストファイルがあるパス\test1.txt" -Encoding utf8

$DivLenArr = @();
foreach ($str in $arr) {
    #write-host $str.Length
    $DivLenArr += $str.Length
}

write-host $DivLenArr

$str2 = $DivLenArr -join ','
$str2 = "(" + $str2 + ")"

$savePath = "C:改行が何文字目で入っているかの情報を出力するファイルのパス\test2.txt";

Set-Content -Path $savePath $str2 -Encoding UTF8


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?