ium_452639/csv2tsv/csv2tsv.go

34 lines
504 B
Go
Raw Normal View History

package main
import (
"encoding/csv"
"fmt"
"io"
"os"
)
func main() {
reader := csv.NewReader(os.Stdin)
reader.FieldsPerRecord = -1
reader.ReuseRecord = true
2023-03-18 17:32:31 +01:00
loop:
for lineno := 0; ; lineno++ {
record, err := reader.Read()
switch err {
case io.EOF:
break loop
default:
fmt.Fprintf(os.Stderr, "[WARNING] Couldn't read line %d: %v\n", lineno, err)
case nil:
}
for i, entry := range record {
if i != 0 {
fmt.Print("\t")
}
fmt.Print(entry)
}
fmt.Println()
}
}