Closed1

Deno で、一行ずつファイルを読み込む

nakasyounakasyou

deno.land/x/std/io の readLines を使う記事が検索でヒットしたが、どうやらそれは非推奨。調べてみたら、 @std/io は従来の Reader という API に関する Utils らしい。
ReadableStream 用のものがないかと deno_std を探してたら、 @std/streams というものを発見。その中に TextLineStream というものがあった。

import { TextLineStream } from '@std/streams'

const file = await Deno.open('./result.csv', {
  read: true
})
for await (const line of file.readable.pipeThrough(new TextDecoderStream()).pipeThrough(new TextLineStream())) {
  console.log(line)
}

https://jsr.io/@std/streams

このスクラップは2ヶ月前にクローズされました