daShangDao_kfzgw-info/csv/test.go
2025-12-22 19:09:56 +08:00

55 lines
1.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
//func main() {
//filename := filepath.Join("csv", "test1.csv")
//handle := openCSVFile(filename, ',', true)
//fmt.Println("handle:", handle)
//
//// 测试1基础写入
//fmt.Println("\n=== 测试1基础写入 ===")
//// 清空并写入新数据
//newRow := make([][]string, 0)
//newRow = append(newRow, []string{"基础测试行5", "基础值5", "基础数据5", "基础测试5"})
//
//for i := 1; i <= 10; i++ {
// row := []string{
// "基础行" + strconv.Itoa(i),
// "基础值" + strconv.Itoa(i),
// "基础数据" + strconv.Itoa(i),
// fmt.Sprintf("基础测试%d", i),
// }
// newRow = append(newRow, row)
//}
//
//start := time.Now()
//rows := writeRows(handle, newRow, 0)
//
//elapsed := time.Since(start)
//fmt.Printf("基础写入完成,影响行数: %d耗时: %v\n", rows, elapsed)
//
//buffer := make([]byte, 4096)
//rowss := readRows(handle, 0, rows, buffer)
//fmt.Printf("读取到 %d 行数据\n", rowss)
//
//decodedRows := decodeRowData(buffer, 4096)
//fmt.Println("合并文件前几行数据:")
//for i, row := range decodedRows {
// if i >= int(rowss) {
// break
// }
// fmt.Printf(" 行 %d: %v\n", i, row)
//}
//// 测试3读写混合
//fmt.Println("\n=== 测试3读写混合 ===")
//testMixedOperations(handle)
//file, err := closeCSVFile(handle)
//if err != nil {
// fmt.Println(err)
//}
//if file == 0 {
// fmt.Println("\n文件保存成功")
//}
//}