| 12345678910111213141516171819202122232425262728293031323334353637 |
- package main
- import (
- "bufio"
- "fmt"
- "log"
- "os"
- )
- // FileToList ...
- func FileToList(filename string) []string {
- var lines []string
- file, err := os.Open(filename)
- if err != nil {
- log.Panic(err)
- }
- scanner := bufio.NewScanner(file)
- scanner.Split(bufio.ScanLines)
- for scanner.Scan() {
- lines = append(lines, scanner.Text())
- }
- file.Close()
- return lines
- }
- func main() {
- fmt.Println("Create script sql")
- ids := FileToList("idskill.txt")
- file, err := os.Create("idskill.sql")
- if err != nil {
- log.Panic(err)
- }
- for n, id := range ids {
- line := fmt.Sprintf("INSERT INTO Por_PortalSkillGroup (PortalSkillGroupId, Skill_DomainId, PortalSkillId) VALUES (%d, %s, %s);\n", n, "262144", id)
- fmt.Fprintf(file, line)
- }
- }
|