Advertisement
Wolfrost

CSV

Apr 6th, 2020
1,129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.34 KB | None | 0 0
  1. var names []string
  2. scanner := bufio.NewScanner(file)
  3. for scanner.Scan() {
  4.     name := scanner.Text()
  5.     for i := 0; i < 4; i++ {
  6.         names = append(names, name)
  7.     }
  8. }
  9.  
  10. newFile, _ := os.Create("new_names.csv")
  11. defer newFile.Close()
  12.  
  13. writer := bufio.NewWriter(newFile)
  14. for _, name := range names {
  15.     _, _ = writer.WriteString(name + "\n")
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement