@@ -23,6 +23,7 @@ import (
2323 "io"
2424 "os"
2525 "path"
26+ "runtime"
2627 "strings"
2728
2829 // Caltech Library packages
@@ -94,7 +95,10 @@ zero. Supports exact match as well as some Levenshtein matching.
9495: set the edit distance thresh hold for match, default 0
9596
9697-nl, -newline
97- : include trailing newline from output
98+ : include trailing newline from output for end of file (EOF)
99+
100+ -crlf
101+ : use CRLF for end of line (EOL) on write, defaults to true for Windows
98102
99103-o, -output
100104: output filename
@@ -182,6 +186,7 @@ You can also search for phrases in columns.
182186 delimiter string
183187 lazyQuotes bool
184188 trimLeadingSpace bool
189+ useCRLF bool
185190)
186191
187192func main () {
@@ -190,6 +195,7 @@ func main() {
190195 license := datatools .LicenseText
191196 releaseDate := datatools .ReleaseDate
192197 releaseHash := datatools .ReleaseHash
198+ useCRLF = (runtime .GOOS == "windows" )
193199
194200 // Basic Options
195201 flag .BoolVar (& showHelp , "help" , false , "display help" )
@@ -224,6 +230,7 @@ func main() {
224230 flag .BoolVar (& trimSpaces , "trimspaces" , false , "trim spaces around cell values before comparing" )
225231 flag .BoolVar (& lazyQuotes , "use-lazy-quotes" , false , "use lazy quotes on CSV input" )
226232 flag .BoolVar (& trimLeadingSpace , "trim-leading-space" , false , "trim leadings space in field(s) for CSV input" )
233+ flag .BoolVar (& useCRLF , "crlf" , useCRLF , "use CRLF for end of line (EOL) on write" )
227234
228235 // Parse env and options
229236 flag .Parse ()
@@ -300,6 +307,7 @@ func main() {
300307 csvIn .LazyQuotes = lazyQuotes
301308 csvIn .TrimLeadingSpace = trimLeadingSpace
302309 csvOut := csv .NewWriter (out )
310+ csvOut .UseCRLF = useCRLF
303311 if delimiter != "" {
304312 csvIn .Comma = datatools .NormalizeDelimiterRune (delimiter )
305313 csvOut .Comma = datatools .NormalizeDelimiterRune (delimiter )
0 commit comments