前言

前面一篇博客讲到nodejs使用readline逐行读取和写入文件
今天使用go语言实现从输入文件中读取每行数据,然后将每行字段组合成SQL插入脚本,然后逐行写入另外一个空白文件中。

tb_param表的结构

tb_param表的结构如下:


创建表的SQL脚本如下,我使用的是Sqlite数据库

 DROP TABLE IF EXISTS "main"."tb_param";
CREATE TABLE tb_param(protocol INT NOT NULL,slave INT NOT NULL,number INT NOT NULL,ptype INT NOT NULL,pid INT NOT NULL,name TEXT NOT NULL,format TEXT,PRIMARY KEY(protocol,slave,number,ptype,pid));

前面使用nodejs实现从input.txt文件逐行读取数据,然后将每行数据拼接成如下的数据格式:

INSERT INTO tb_param (protocol, slave, number, ptype, pid, name, format)
VALUES (2, 6, 0, 1, 1, 'a34004', .0);

输入文件 input.txt示例如下:

2    24  0   1   1   a04005  .3
2   24  0   1   2   a04006  .3
2   24  0   1   3   a04007  .3
2   16  0   1   1   a99501  .3
2   16  0   1   2   a99502  .3
2   16  0   1   3   a99500  .3
2   16  0   1   4   a99505  .3
2   16  0   1   5   a99504  .3
2   16  0   1   6   a99503  .3
2   22  0   1   23  a24901  .3
2   22  0   1   27  a24904  .3
2   22  0   1   28  a24905  .3
2   22  0   1   29  a24042  .3
2   22  0   1   36  a25002  .3
2   22  0   1   33  a24036  .3
2   22  0   1   32  a24908  .3
2   22  0   1   34  a24909  .3
2   22  0   1   35  a24910  .3
2   22  0   1   37  a24012  .3
2   22  0   1   38  a24043  .3
2   22  0   1   39  a24084  .3
2   22  0   1   40  a24911  .3
2   22  0   1   43  a25003  .3
2   22  0   1   41  a24912  .3
2   22  0   1   42  a24913  .3
2   22  0   1   44  a24070  .3
2   22  0   1   45  a25004  .3
2   22  0   1   47  a25008  .3
2   22  0   1   49  a25038  .3
2   22  0   1   48  a25006  .3
2   22  0   1   46  a24044  .3
2   22  0   1   50  a25034  .3
2   22  0   1   51  a25033  .3
2   22  0   1   52  a25902  .3
2   22  0   1   53  a25014  .3
2   22  0   1   55  a25021  .3
2   22  0   1   56  a25901  .3
2   22  0   1   57  a25019  .3
2   22  0   1   54  a24068  .3
2   22  0   1   58  a25020  .3
2   22  0   1   59  a25903  .3
2   22  0   1   60  a25904  .3
2   22  0   1   61  a24914  .3
2   22  0   1   62  a24915  .3
2   22  0   1   1   a24001  .3
2   22  0   1   2   a24045  .3
2   22  0   1   3   a24002  .3
2   22  0   1   4   a24053  .3
2   22  0   1   5   a24038  .3
2   22  0   1   6   a24037  .3
2   22  0   1   7   a24079  .3
2   22  0   1   8   a24064  .3
2   22  0   1   11  a24063  .3
2   22  0   1   12  a24902  .3
2   22  0   1   13  a24041  .3
2   22  0   1   14  a24039  .3
2   22  0   1   20  a24077  .3
2   22  0   1   18  a24074  .3
2   22  0   1   22  a24076  .3
2   22  0   1   31  a24907  .3
2   22  0   1   24  a24903  .3
2   22  0   1   25  a24011  .3
2   22  0   1   21  a24061  .3
2   22  0   1   30  a24906  .3
2   22  0   1   104 a31005  .3
2   22  0   1   206 a24072  .3
2   22  0   1   221 a05009  .3
2   22  0   1   65  a05014  .3
2   22  0   1   66  a24099  .3
2   22  0   1   67  a24046  .3
2   22  0   1   15  a24078  .3
2   22  0   1   68  a24008  .3
2   22  0   1   69  a24015  .3
2   22  0   1   70  a24916  .3
2   22  0   1   96  a31004  .3
2   22  0   1   97  a31003  .3
2   22  0   1   72  a24047  .3
2   22  0   1   71  a05013  .3
2   22  0   1   98  a31024  .3
2   22  0   1   73  a24100  .3
2   22  0   1   74  a24003  .3
2   22  0   1   101 a28006  .3
2   22  0   1   75  a24016  .3
2   22  0   1   76  a24111  .3
2   22  0   1   77  a24004  .3
2   22  0   1   78  a24018  .3
2   22  0   1   79  a24005  .3
2   22  0   1   80  a24017  .3
2   22  0   1   81  a24049  .3
2   22  0   1   82  a24027  .3
2   22  0   1   83  a24007  .3
2   22  0   1   85  a24112  .3
2   22  0   1   84  a24054  .3
2   22  0   1   86  a24019  .3
2   22  0   1   87  a24050  .3
2   22  0   1   88  a24034  .3
2   22  0   1   89  a25010  .3
2   22  0   1   90  a24009  .3
2   22  0   1   91  a24020  .3
2   22  0   1   92  a25012  .3
2   22  0   1   95  a25011  .3
2   22  0   1   215 a30008  .3
2   22  0   1   219 a99051  .3
2   22  0   1   201 a29026  .3
2   22  0   1   208 a29017  .3
2   22  0   1   106 a31025  .3
2   22  0   1   209 a24110  .3
2   22  0   1   203 a25072  .3
2   22  0   1   222 a29015  .3
2   22  0   1   202 a31030  .3
2   22  0   1   211 a31027  .3
2   22  0   1   207 a24006  .3
2   22  0   1   93  a25013  .3
2   22  0   1   94  a25068  .3
2   22  0   1   204 a25015  .3
2   22  0   1   223 a24113  .3
2   22  0   1   224 a25059  .3
2   22  0   1   9   a24919  .3
2   22  0   1   213 a30003  .3
2   17  0   1   1   a99070  .0
2   17  0   1   2   a99071  .0
2   17  0   1   3   a99072  .0
2   17  0   1   4   a99073  .0
2   17  0   1   5   a99074  .0
2   17  0   1   6   a99075  .0
2   17  0   1   7   a99076  .0
2   17  0   1   8   a99077  .0
2   17  0   1   9   a99078  .0
2   17  0   1   10  a99079  .0
2   17  0   1   11  a99080  .0
2   17  0   1   12  a99081  .0
2   17  0   1   13  a99082  .0
2   17  0   1   14  a99083  .0
2   17  0   1   15  a99084  .0
2   17  0   1   16  a99085  .0
2   17  0   1   17  a99086  .0
2   17  0   1   18  a99087  .0
2   17  0   1   19  a99088  .0
2   17  0   1   20  a99089  .0
2   17  0   1   21  a99090  .0
2   17  0   1   22  a99091  .0
2   17  0   1   23  a99092  .0
2   17  0   1   24  a99093  .0
2   17  0   1   25  a99094  .0
2   17  0   1   26  a99095  .0
2   17  0   1   27  a99096  .0
2   17  0   1   28  a99097  .0
2   17  0   1   29  a99098  .0
2   17  0   1   30  a99099  .0
2   17  0   1   31  a99100  .0
2   17  0   1   32  a99101  .0
2   17  0   1   35  a99102  .1
2   17  0   1   36  a99103  .1
2   17  0   1   37  a99104  .1

Go语言实现代码

readFile.go 代码如下:

package mainimport ("fmt""os""bufio""strconv""strings"
)func main() {// open the file filepathfRead, err := os.Open("./input.txt")if err != nil {fmt.Println("failed open the file input.txt")panic(err)}defer fRead.Close()// 创建输出文件 output.txt 用于存放输出结果strDestFileName := "./output.txt"fWrite, err2 := os.Create(strDestFileName)if err2 != nil {fmt.Println(err.Error())panic(err2)}defer fWrite.Close()// create a scannerfs := bufio.NewScanner(fRead)// scan file// https://golang.org/pkg/bufio/#Scanner.Scanfor fs.Scan() {strLine := fs.Text()// do anything with strLinefmt.Println(strLine)strLineSplit := strings.Split(strLine, "\t")strProtocol := strLineSplit[0]strSlave := strLineSplit[1]strNumber := strLineSplit[2]strPtype := strLineSplit[3]strPid := strLineSplit[4]strName := strLineSplit[5]strFormat := strLineSplit[6]iProtocol, err3 := strconv.Atoi(strProtocol)if err3 != nil {fmt.Println("转换strProtocol从string到int失败")panic(err3)}iSlave, err4 := strconv.Atoi(strSlave)if err4 != nil {fmt.Println("转换strSlave从string到int失败")panic(err4)}iNumber, err5 := strconv.Atoi(strNumber)if err5 != nil {fmt.Println("转换strNumber从string到int失败")panic(err5)}iPtype, err6 := strconv.Atoi(strPtype)if err6 != nil {fmt.Println("转换strPtype从string到int失败")panic(err6)}iPid, err7 := strconv.Atoi(strPid)if err7 != nil {fmt.Println("转换strPid从string到int失败")panic(err7)}// 根据读取到的每行数据,按照指定格式拼接成SQL插入脚本,按\n换行符进行分割strResult := fmt.Sprintf("INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)\n " +" VALUES(%d, %d, %d, %d, %d, '%v', '%v')\n", iProtocol, iSlave, iNumber, iPtype, iPid, strName, strFormat)// 将格式化处理的每行数据写入到文件output.txt中fWrite.WriteString(strResult)// fmt.Fprintf(fWrite, strResult)}
}

运行上述代码并获得输出

go run readFile.go

得到输出文件output.txt如下所示:

INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 24, 0, 1, 1, 'a04005', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 24, 0, 1, 2, 'a04006', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 24, 0, 1, 3, 'a04007', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 16, 0, 1, 1, 'a99501', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 16, 0, 1, 2, 'a99502', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 16, 0, 1, 3, 'a99500', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 16, 0, 1, 4, 'a99505', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 16, 0, 1, 5, 'a99504', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 16, 0, 1, 6, 'a99503', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 23, 'a24901', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 27, 'a24904', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 28, 'a24905', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 29, 'a24042', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 36, 'a25002', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 33, 'a24036', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 32, 'a24908', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 34, 'a24909', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 35, 'a24910', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 37, 'a24012', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 38, 'a24043', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 39, 'a24084', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 40, 'a24911', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 43, 'a25003', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 41, 'a24912', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 42, 'a24913', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 44, 'a24070', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 45, 'a25004', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 47, 'a25008', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 49, 'a25038', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 48, 'a25006', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 46, 'a24044', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 50, 'a25034', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 51, 'a25033', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 52, 'a25902', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 53, 'a25014', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 55, 'a25021', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 56, 'a25901', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 57, 'a25019', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 54, 'a24068', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 58, 'a25020', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 59, 'a25903', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 60, 'a25904', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 61, 'a24914', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 62, 'a24915', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 1, 'a24001', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 2, 'a24045', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 3, 'a24002', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 4, 'a24053', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 5, 'a24038', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 6, 'a24037', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 7, 'a24079', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 8, 'a24064', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 11, 'a24063', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 12, 'a24902', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 13, 'a24041', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 14, 'a24039', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 20, 'a24077', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 18, 'a24074', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 22, 'a24076', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 31, 'a24907', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 24, 'a24903', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 25, 'a24011', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 21, 'a24061', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 30, 'a24906', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 104, 'a31005', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 206, 'a24072', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 221, 'a05009', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 65, 'a05014', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 66, 'a24099', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 67, 'a24046', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 15, 'a24078', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 68, 'a24008', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 69, 'a24015', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 70, 'a24916', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 96, 'a31004', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 97, 'a31003', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 72, 'a24047', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 71, 'a05013', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 98, 'a31024', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 73, 'a24100', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 74, 'a24003', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 101, 'a28006', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 75, 'a24016', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 76, 'a24111', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 77, 'a24004', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 78, 'a24018', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 79, 'a24005', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 80, 'a24017', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 81, 'a24049', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 82, 'a24027', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 83, 'a24007', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 85, 'a24112', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 84, 'a24054', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 86, 'a24019', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 87, 'a24050', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 88, 'a24034', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 89, 'a25010', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 90, 'a24009', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 91, 'a24020', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 92, 'a25012', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 95, 'a25011', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 215, 'a30008', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 219, 'a99051', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 201, 'a29026', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 208, 'a29017', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 106, 'a31025', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 209, 'a24110', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 203, 'a25072', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 222, 'a29015', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 202, 'a31030', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 211, 'a31027', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 207, 'a24006', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 93, 'a25013', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 94, 'a25068', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 204, 'a25015', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 223, 'a24113', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 224, 'a25059', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 9, 'a24919', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 22, 0, 1, 213, 'a30003', '.3')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 1, 'a99070', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 2, 'a99071', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 3, 'a99072', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 4, 'a99073', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 5, 'a99074', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 6, 'a99075', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 7, 'a99076', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 8, 'a99077', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 9, 'a99078', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 10, 'a99079', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 11, 'a99080', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 12, 'a99081', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 13, 'a99082', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 14, 'a99083', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 15, 'a99084', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 16, 'a99085', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 17, 'a99086', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 18, 'a99087', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 19, 'a99088', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 20, 'a99089', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 21, 'a99090', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 22, 'a99091', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 23, 'a99092', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 24, 'a99093', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 25, 'a99094', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 26, 'a99095', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 27, 'a99096', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 28, 'a99097', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 29, 'a99098', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 30, 'a99099', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 31, 'a99100', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 32, 'a99101', '.0')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 35, 'a99102', '.1')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 36, 'a99103', '.1')
INSERT INTO tb_param(protocol, slave, number, ptype, pid, name, format)VALUES(2, 17, 0, 1, 37, 'a99104', '.1')

参考资料

  • go语言按行读取文件
  • golang 逐行写文件_如何在Go中逐行处理文件?
  • How to process a file line by line in Go?
  • golang 中string和int类型相互转换
  • Golang文件写入的四种方式
  • Go 语言 fmt.Sprintf (格式化输出)

go语言逐行读取和写入文件相关推荐

  1. python读取写入文件_Python读取和写入文件

    1 从文件中读取数据 1.1 读取整个文件 创建名为test的txt文本文件,添加内容如下所示: 1234567890 2345678901 3456789012 实现代码: with open('t ...

  2. C 语言 边读 边写入文件

    读入一个文本文件中的字符串,对给定的patten进行甄别并修改. 利用边甄别,边转换,边写入的办法实现 方法: 1. 把原文件改名,然后新建一个与原文件名相同的文件(目的文件),然后读取原文件,转换后 ...

  3. sublime python3中读取和写入文件时如何解决编码问题

    sublime python3中读取和写入文件时如何解决编码问题 参考文章: (1)sublime python3中读取和写入文件时如何解决编码问题 (2)https://www.cnblogs.co ...

  4. java写入文件编码格式为ansi_Java读取、写入文件如何解决乱码问题

    读取文件流时,经常会遇到乱码的现象,造成乱码的原因当然不可能是一个,这里主要介绍因为文件编码格式而导致的乱码的问题.首先,明确一点,文本文件与二进制文件的概念与差异. 文本文件是基于字符编码的文件,常 ...

  5. Flutter进阶—读取与写入文件

    Flutter使用path_provider插件读取与写入文件,path_provider插件提供了一种平台无关的方法来访问设备文件系统上常用的位置.该类目前支持访问两个文件系统位置: 临时目录:系统 ...

  6. 读取和写入文件的最简单方法

    本文翻译自:Easiest way to read from and write to files There are a lot of different ways to read and writ ...

  7. VS语音信号处理(2) C语言分段读取WAV语音文件语音数据

    VS语音信号处理(2) C语言分段读取WAV语音文件语音数据 前言 一. 工程实现 二. 结果 三. 小结 前言 语音识别相关算法一般在MATLAB上进行仿真验证与实验,在工程上一般还是在VS中进行实 ...

  8. nodejs:fs (内置模块)读取和写入文件

    node fs (内置模块)读取和写入文件 const fs = require("fs"); //异步读取文件 fs.readFile("data.txt", ...

  9. HttpWebRequest FileStream分块读取和写入文件WebClient

    //HttpWebRequest  下载文件 private void DownloadFile(string filePath)           {               string[] ...

最新文章

  1. iOS Core Data
  2. 【调试基础】Part 3 Window操作系统
  3. 经典C语言程序100例之二七
  4. Docker启动tomcat,访问首页出现404错误
  5. Java黑皮书课后题第5章:*5.48(处理字符串)编写一个程序,提示用户输入一个字符串,显示奇数位置的字符
  6. 为什么 SQL 正在击败 NoSQL,这对未来的数据意味着什么?
  7. 事关SuperSocket发布,寻找YangFan哥哥
  8. uni app 调用网络打印机_uni-app 的使用体验总结
  9. 终端mysql Operation not permitted错误解决方案
  10. 不起眼的vim.转自https://blog.csdn.net/iplayvs2008/article/details/51508599
  11. Mac下Chrome添加.crx浏览器插件
  12. web前端学习(二十八)——CSS3下拉菜单的相关设置
  13. Spring全家桶视频教程
  14. VC++ 判断打印机状态
  15. movs 数据传送指令_深入理解计算机系统(3.3)---数据传送(或者说复制)指令详解...
  16. GooglePlay商店如何优化
  17. 三位数除以两位数竖式计算没有余数_四年级上册数学三位数除两位数练习题没有余数...
  18. 看了这个才发现jQuery源代码不是那么晦涩
  19. python下载酷狗音乐源码
  20. python nose

热门文章

  1. 互联网企业基本生命线
  2. selenium淘宝登录和滑块破解最新可用
  3. 解决windows未识别的网络问题
  4. Vitamio视频播放器
  5. 路由器与ospf协议的深入了解。
  6. python 显示界片_在shapefile(Python)中查找面片子集的贴图边界
  7. 用四个元件,轻松做一个升压电路
  8. matlab一直系统函数画脉冲响应,MATLAB之使用 impz 函数计算并画出脉冲响应
  9. 全网最细!PyCharm 详细使用指南
  10. n维单位正交向量和他的转秩α*α^T性质