bmx-ng / text.mod

Text Utilities
0 stars 3 forks source link

CSV option insertHeaderRow not working #10

Closed thareh closed 1 year ago

thareh commented 1 year ago

Hey,

Seems like the option insertHeaderRow is not working.

Framework BRL.Blitz
Import BRL.StandardIO
Import Text.CSV

Local stream:TStream = ReadStream("data.csv")

Local opts:TCsvOptions = New TCsvOptions()
opts.delimiter = ","
opts.insertHeaderRow = "col1,col2,col3"

Local csv:TCsvParser = TCsvParser.Parse(stream, opts)

Repeat
    Local status:ECsvStatus = csv.NextRow()

    If status <> ECsvStatus.row
        Exit
    EndIf

    Local row:TCSVRow = csv.GetRow()
    Local count:Int = row.ColumnCount()

    For Local i:Int = 0 Until count
        Local header:TCsvHeader = row.GetHeader()

        Print header.GetHeader(Size_T(i)) + ": " + row.GetColumn(Size_T(i)).GetValue()
    Next
Forever

Print "Done!"

data.csv

row1col1,row1col2,row1col3
row2col1,row2col2,row2col3

Thanks!

woollybah commented 1 year ago

This appears to be working with the latest zsv?

thareh commented 1 year ago

Indeed, thank you.