Skip to content

Instantly share code, notes, and snippets.

@yfuruyama
Created December 18, 2020 03:41
Show Gist options
  • Save yfuruyama/1458aad949c5f89f0e3cf5715b579ed1 to your computer and use it in GitHub Desktop.
Save yfuruyama/1458aad949c5f89f0e3cf5715b579ed1 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/csv"
"io"
"log"
"os"
)
func main() {
reader := csv.NewReader(os.Stdin)
reader.Comma = '\t'
reader.LazyQuotes = true
writer := csv.NewWriter(os.Stdout)
for {
record, err := reader.Read()
if err == io.EOF {
break
}
if err != nil {
log.Fatalf("unexpected error on read: %v", err)
}
if err := writer.Write(record); err != nil {
log.Fatalf("unexpected error on write: %v", err)
}
}
writer.Flush()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment