You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmds/csvcleaner/csvcleaner.go
+32-29Lines changed: 32 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -48,15 +48,15 @@ Normalizing a spread sheet's column count to 5 padding columns as needed per row
48
48
49
49
cat mysheet.csv | %s -field-per-row=5
50
50
51
-
Trim leading spaces.
51
+
Trim leading spaces from output.
52
52
53
53
cat mysheet.csv | %s -left-trim
54
54
55
-
Trim trailing spaces.
55
+
Trim trailing spaces from output.
56
56
57
57
cat mysheet.csv | %s -right-trim
58
58
59
-
Trim leading and trailing spaces
59
+
Trim leading and trailing spaces from output.
60
60
61
61
cat mysheet.csv | %s -trim
62
62
`
@@ -74,18 +74,19 @@ Trim leading and trailing spaces
74
74
//eol string
75
75
76
76
// App Options
77
-
commastring
78
-
rowCommentstring
79
-
fieldsPerRecordint
80
-
lazyQuotesbool
81
-
trailingCommabool
82
-
trimSpacebool
83
-
trimLeadingSpacebool
84
-
trimTrailingSpacebool
85
-
reuseRecordbool
86
-
commaOutstring
87
-
useCRLFbool
88
-
stopOnErrorbool
77
+
commastring
78
+
rowCommentstring
79
+
fieldsPerRecordint
80
+
trailingCommabool
81
+
trimSpacebool
82
+
trimLeftSpacebool
83
+
trimRightSpacebool
84
+
reuseRecordbool
85
+
commaOutstring
86
+
useCRLFbool
87
+
stopOnErrorbool
88
+
lazyQuotesbool
89
+
trimLeadingSpacebool
89
90
90
91
verbosebool
91
92
)
@@ -112,16 +113,17 @@ func main() {
112
113
113
114
// Application specific options
114
115
app.IntVar(&fieldsPerRecord, "fields-per-row", 0, "set the number of columns to output right padding empty cells as needed")
115
-
app.BoolVar(&lazyQuotes, "use-lazy-quoting", false, "If LazyQuotes is true, a quote may appear in an unquoted field and a non-doubled quote may appear in a quoted field.")
116
-
app.BoolVar(&trimSpace, "trim", false, "If set to true leading and trailing white space in a field is ignored.")
117
-
app.BoolVar(&trimLeadingSpace, "left-trim", false, "If set to true leading white space in a field is ignored.")
118
-
app.BoolVar(&trimTrailingSpace, "right-trim", false, "If set to true trailing white space in a field is ignored.")
116
+
app.BoolVar(&trimSpace, "trim", false, "trim spaces on CSV out")
117
+
app.BoolVar(&trimLeftSpace, "left-trim", false, "left trim spaces on CSV out")
118
+
app.BoolVar(&trimRightSpace, "right-trim", false, "right trim spaces on CSV out")
119
119
app.BoolVar(&reuseRecord, "reuse", true, "if false then a new array is allocated for each row processed, if true the array gets reused")
120
120
app.StringVar(&comma, "comma", "", "if set use this character in place of a comma for delimiting cells")
121
121
app.StringVar(&rowComment, "comment-char", "", "if set, rows starting with this character will be ignored as comments")
122
122
app.StringVar(&commaOut, "output-comma", "", "if set use this character in place of a comma for delimiting output cells")
123
123
app.BoolVar(&useCRLF, "use-crlf", false, "if set use a charage return and line feed in output")
124
124
app.BoolVar(&stopOnError, "stop-on-error", false, "exit on error, useful if you're trying to debug a problematic CSV file")
125
+
app.BoolVar(&lazyQuotes, "use-lazy-quotes", false, "use lazy quotes for CSV input")
126
+
app.BoolVar(&trimLeadingSpace, "trim-leading-space", false, "trim leading space from field(s) for CSV input")
125
127
126
128
app.BoolVar(&verbose, "V,verbose", false, "write verbose output to standard error")
127
129
@@ -162,16 +164,10 @@ func main() {
162
164
fmt.Fprintln(app.Out, app.Version())
163
165
os.Exit(0)
164
166
}
165
-
/*
166
-
if newLine {
167
-
eol = "\n"
168
-
}
169
-
*/
170
167
171
168
// Loop through input CSV, apply options, write to output CSV
0 commit comments