Guest User

Untitled

a guest
Nov 17th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "encoding/csv"
  5. "fmt"
  6. "os"
  7. )
  8.  
  9. func main() {
  10. file, _ := os.OpenFile("test.csv", os.O_WRONLY|os.O_CREATE, os.ModePerm)
  11. w := csv.NewWriter(file)
  12. w.Write([]string{"123", "234234", "345345", "234234"})
  13. w.Flush()
  14.  
  15. file.Close()
  16.  
  17. rfile, _ := os.Open("test.csv")
  18. r := csv.NewReader(rfile)
  19. strs, _ := r.Read()
  20. for _, str := range strs {
  21. fmt.Print(str, "\t")
  22. }
  23. }
Add Comment
Please, Sign In to add comment