本文整理汇总了Golang中encoding/csv.Writer类的典型用法代码### 示例。如果您正苦于以下问题:Golang Writer类的具体用法?Golang Writer怎么用?Golang Writer使用的例子?那么恭喜您, 这里精选的类代码### 示例或许可以为您提供帮助。

在下文中一共展示了Writer类的20个代码### 示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码### 示例。

示例1: writePromptInText

func writePromptInText(pId string, pc PromptConfig, writer *csv.Writer, level int, evalue ExpectedResponseValue) {
    indent := ""
    pPromptType := ""
    for i := 0; i < level; i++ {
        indent = indent + "    "
    }
    if pId == "" {
        pId = pc.Id
        pPromptType = pc.PromptType
    }
    pId = indent + pId
    pText := pc.Text
    supportPromptId := pc.SupportPromptRef.Id
    var value = []string{strconv.Itoa(level), pId, pPromptType, evalue.Id, supportPromptId, "", "", ""}
    for i, v := range pText {
        value[5+i] = v
    }
    err := writer.Write(value)
    if err != nil {
        log.Fatal("Cannot write file", err)
    }
    level++
    ecs := pc.ExpectedResponses.Values
    for _, v := range ecs {
        writePromptInText(v.NextPromptRef.Id, v.NextPrompt, writer, level, v)
    }
}

开发者ID:toisin,项目名称:astro-world,代码行数:27,代码来源:workflow.go

示例2: writeOneRecordAtaTime

func writeOneRecordAtaTime(writer *csv.Writer, data [][]string) {

    for _, row := range data {
        writer.Write(row)
    }
    writer.Flush()
}

开发者ID:robertojrojas,项目名称:go-database-frameworks-and-tools,代码行数:7,代码来源:main.go

示例3: flush

func (p *csvProcessor) flush(writer *csv.Writer, err error) error {
    if err != nil {
        return err
    }
    writer.Flush()
    return writer.Error()
}

开发者ID:jchannon,项目名称:negotiator,代码行数:7,代码来源:csvprocessor.go

示例4: writeSalesData

func writeSalesData(conn *sql.DB, writer *csv.Writer, first int, last int, wg *sync.WaitGroup) {
    defer wg.Done()

    rows, err := conn.Query("select * from sales where id between ? and ?", first, last)
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    var orderId int
    var userId int
    var orderAmount float64

    for rows.Next() {
        rows.Scan(&orderId, &userId, &orderAmount)

        writer.Write([]string{
            strconv.Itoa(orderId),
            strconv.Itoa(userId),
            strconv.FormatFloat(orderAmount, 'f', 6, 64),
        },
        )
    }

    writer.Flush()
}

开发者ID:callmegarrus,项目名称:some_task,代码行数:26,代码来源:modified_solution.go

示例5: csvExporter

func csvExporter(c *csv.Writer, ms []*Metric) {
    lc := make(chan *LabelSet)
    quit := make(chan bool)
    for _, m := range ms {
        go m.EmitLabelSets(lc, quit)
        for {
            select {
            case l := <-lc:
                record := []string{m.Program,
                    m.Name,
                    m.Kind.String()}
                for k, v := range l.labels {
                    record = append(record, k, v)
                }
                record = append(record, fmt.Sprintf("%s", l.datum.Time))
                record = append(record, fmt.Sprintf("%d", l.datum.Get()))
                err := c.Write(record)
                if err != nil {
                    log.Printf("Failed to write csv record %q: %s\n", record, err)
                }
            case <-quit:
                goto next
            }
        }
    next:
    }
}

开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:27,代码来源:export.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng