Comments (11)
I just released version 0.7.4 for this issue.
Thank you.
from trdsql.
Works great!! Thanx
from trdsql.
As you said, the output of CSV is not flexible.
The encoding/csv is used for CSV output.
https://golang.org/pkg/encoding/csv/
In this package, it is output in double quotation only when necessary.
echo 'a,b,c"d'|trdsql -ocsv "SELECT * FROM -"
a,b,"c""d"
If you really need it, I would like to be added to golang package CSV.
from trdsql.
I just released v0.6.1.
It can be used as a library.
You may be able to resolve this issue.
With the following code:
package main
import (
"io"
"log"
"os"
"strconv"
"strings"
"github.com/noborus/trdsql"
)
type QuoteWrite struct {
writer io.Writer
}
func NewQuoteCSVWriter(w io.Writer) *QuoteWrite {
return &QuoteWrite{
writer: w,
}
}
func (w *QuoteWrite) PreWrite(columns []string, types []string) error {
return nil
}
func (w *QuoteWrite) WriteRow(values []interface{}, columns []string) error {
qColumns := make([]string, len(values))
for i, col := range values {
qColumns[i] = strconv.Quote(trdsql.ValString(col))
}
_, err := w.writer.Write([]byte(strings.Join(qColumns, ",") + "\n"))
return err
}
func (w *QuoteWrite) PostWrite() error {
return nil
}
func main() {
trd := trdsql.NewTRDSQL(
trdsql.NewImporter(),
trdsql.NewExporter(NewQuoteCSVWriter(os.Stdout)),
)
err := trd.Exec("SELECT * FROM testdata/test.csv")
if err != nil {
log.Fatal(err)
}
}
from trdsql.
I really love to use trdsql, awful speed and possibilities!
In processing large log-files the lack of being able to generate output with quotes is bugging me
Here you state:
You can right now configure the separator character with -od
A similar one for quotes could be added
Could you please add this to possible -od output options?
from trdsql.
Thank you for your opinion.
Force quotes are not supported by the standard CSV module.
So, before adding the option, consider using another CSV writer or implementing one.
from trdsql.
So, before adding the option, consider using another CSV writer or implementing one.
It concerns the activitylog from Twillio SendGrid, so, no chance of getting it changed.
from trdsql.
Sorry. Change the 'encoding/csv' part.
For example, you can change https://github.com/tushar2708/altcsv to use.
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)
}
from trdsql.
I added a new option to address this issue (#118) .
I want your opinion on this option.
If the name or description of the added option is not appropriate, please indicate it.
Added are - oq and - oaq and - ocrlf.
from trdsql.
Looks fine to me.
I'll wait for a new release to test it.
from trdsql.
Looks fine to me.
I'll wait for a new release to test it.
Thank you very much.
from trdsql.
Related Issues (20)
- Want to get Integer values from JSON data instead of exponential notation HOT 1
- UTF-8 Byte Order Markers should be ignored HOT 1
- -driver postgres returns SSL error HOT 2
- Not able to use JSON_EXTRACT HOT 2
- Can't you use the WHERE statement? HOT 5
- build Dockerfile with multi-stage ? It also supports ARM64 HOT 2
- `CREATE TABLE AS` and` INSERT INTO table SELECT` Is output as an example of SQL
- Question. Can trdsql query by a column has no value(null or empty) HOT 5
- binary is not completely statically compiled HOT 5
- "null" representation HOT 1
- Specifying column types HOT 3
- Multiple queries HOT 2
- Support for DuckDB HOT 1
- `-ijq` does not work correctly from stdin HOT 1
- Error: Cannot tap noborus/tap: invalid syntax in tap! HOT 1
- Cannot use the tool, process gets instantly killed with 137 exit code HOT 13
- support logfmt
- feature request: support input format yaml file HOT 2
- feature request: automatically quote columns HOT 1
- Brew SHA256 Mismatch HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trdsql.