Skip to content

Commit 65e1d8f

Browse files
committed
added csv flag
1 parent 60bf7bd commit 65e1d8f

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

godiff.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ func main() {
310310

311311
flag.StringVar(&flag_p_keys, "key", "", "The Primary Key Columns")
312312
flag.StringVar(&flag_html_output, "html", flag_html_output, "Generate HTML diff file")
313+
flag.StringVar(&flag_csv_delta, "csv", flag_csv_delta, "Generate CSV delta file")
313314
//flags.StringVar(&numericKey, "numeric", "", "The specified columns are treated as numeric strings.")
314315
//flags.StringVar(&reverseKey, "reverse", "", "The specified columns are sorted in reverse order.")
315316

htmlgen.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ func (chg *DiffChangerHtml) diff_lines(ops []DiffOp) {
138138
case DIFF_OP_INSERT:
139139
write_html_blanks(&chg.buf1, v.end2-v.start2)
140140
write_html_lines(&chg.buf2, "add", chg.file2[v.start2:v.end2], v.start2, chg.lineno_width)
141+
writeDiffCSVDelta(&chg.diffbuf, chg.file2[v.start2])
141142

142143
case DIFF_OP_REMOVE:
143144
write_html_lines(&chg.buf1, "del", chg.file1[v.start1:v.end1], v.start1, chg.lineno_width)

utils/csvutils.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ func ColumnReorder(filePath string, columns []int) {
3535
}
3636
}
3737

38+
/*func writeDiffCSVDelta(buf *bytes.Buffer, line []byte) {
39+
buf.Write(line)
40+
buf.WriteString("\n")
41+
}
42+
43+
func writeToFile(filePath string, buf []byte) {
44+
wFile, err := os.Create(filePath) //".colreordered"
45+
if err != nil {
46+
usage(err.Error())
47+
}
48+
defer output_csv_file.Close()
49+
50+
outCSV := bufio.NewWriter(output_csv_file)
51+
outCSV.WriteString(strings.Join(csvHeaderData, ","))
52+
outCSV.WriteString("\n")
53+
outCSV.Write(buf)
54+
outCSV.Flush()
55+
}*/
56+
3857
func getWriter(filePath string) (*csv.Writer, *os.File) {
3958
// Creating csv writer
4059
wFile, err := os.Create(filePath + ".colreordered")

0 commit comments

Comments
 (0)