-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve CSV output formatting to include quotation characters #33
Comments
As you said, the output of CSV is not flexible. The encoding/csv is used for CSV output. In this package, it is output in double quotation only when necessary.
If you really need it, I would like to be added to golang package CSV. |
I just released v0.6.1.
|
I really love to use trdsql, awful speed and possibilities! Here you state:
Could you please add this to possible -od output options? |
Thank you for your opinion. |
It concerns the activitylog from Twillio SendGrid, so, no chance of getting it changed. |
Sorry. Change the 'encoding/csv' part. I haven't decided yet what to do, but I'm considering changing it to not use encoding/csv. diff --git a/output_csv.go b/output_csv.go
index 7b7b345..da337bd 100644
--- a/output_csv.go
+++ b/output_csv.go
@@ -1,12 +1,12 @@
package trdsql
import (
- "encoding/csv"
+ "github.com/tushar2708/altcsv"
)
// CSVWriter provides methods of the Writer interface.
type CSVWriter struct {
- writer *csv.Writer
+ writer *altcsv.Writer
results []string
outHeader bool
}
@@ -15,8 +15,9 @@ type CSVWriter struct {
func NewCSVWriter(writeOpts *WriteOpts) *CSVWriter {
var err error
w := &CSVWriter{}
- w.writer = csv.NewWriter(writeOpts.OutStream)
+ w.writer = altcsv.NewWriter(writeOpts.OutStream)
w.writer.Comma, err = delimiter(writeOpts.OutDelimiter)
+ w.writer.AllQuotes = true
if err != nil {
debug.Printf("%s\n", err)
}
|
Remove use of encoding/csv, and output CSV in writer. Added option to specify quote character. Option to set CRLF at the end of line. CSV output performance has been improved.
I added a new option to address this issue (#118) . |
Looks fine to me. |
Thank you very much. |
Added option to quote all columns with quotes(#33)
I just released version 0.7.4 for this issue. |
Works great!! Thanx |
When for example you have a source file like this
"col1","col2" "dat1","dat2"
And output it as -ocsv the results are
col1,col2 dat1,dat2
You can right now configure the separator character with -od
A similar one for quotes could be added
The text was updated successfully, but these errors were encountered: