Skip to content

Commit bb8987b

Browse files
authored
Merge pull request #293 from noborus/add-text-format-ext
Add extension support for text format
2 parents 11af483 + 253bdbc commit bb8987b

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

README.md

+42-6
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ For usage as a library, please refer to the [godoc](https://pkg.go.dev/github.co
5151
* 4.12. [YAML](#yaml)
5252
* 4.13. [TBLN](#tbln)
5353
* 4.14. [WIDTH](#width)
54-
* 4.15. [Raw output](#raw-output)
55-
* 4.16. [ASCII Table & MarkDown output](#ascii-table-&-markdown-output)
56-
* 4.17. [Vertical format output](#vertical-format-output)
54+
* 4.15. [TEXT](#text)
55+
* 4.16. [Raw output](#raw-output)
56+
* 4.17. [ASCII Table & MarkDown output](#ascii-table-&-markdown-output)
57+
* 4.18. [Vertical format output](#vertical-format-output)
5758
* 5. [SQL](#sql)
5859
* 5.1. [SQL function](#sql-function)
5960
* 5.2. [JOIN](#join)
@@ -185,6 +186,7 @@ trdsql -o[output format] -t [input filename]
185186
* `-iyaml` YAML format for input.
186187
* `-itbln` TBLN format for input.
187188
* `-iwidth` width specification format for input.
189+
* `-itext` text format for input.
188190

189191
#### 3.2.1. <a name='input-options'></a>Input options
190192

@@ -193,6 +195,7 @@ trdsql -o[output format] -t [input filename]
193195
* `-ijq` **string** jq expression string for input(JSON/JSONL only).
194196
* `-ilr` **int** limited number of rows to read.
195197
* `-inull` **string** value(string) to convert to null on input.
198+
* `-inum` add row number column.
196199
* `-ir` **int** number of rows to preread. (default 1)
197200
* `-is` **int** skip header row.
198201

@@ -792,7 +795,40 @@ But `-id " "` does not recognize spaces in columns very well.
792795

793796
`-iwidth` recognizes column widths and space separators.
794797

795-
### 4.15. <a name='raw-output'></a>Raw output
798+
### 4.15. <a name='text'></a>TEXT
799+
800+
The `-itext` option or files with “.text”extension are in text format.
801+
802+
This is a one line to one column format.
803+
A blank line is also a line, unlike the `CSV` format.
804+
805+
```console
806+
$ cat test.text
807+
a
808+
809+
b
810+
811+
c
812+
$ trdsql -itext "SELECT * FROM test.text"
813+
a
814+
815+
b
816+
817+
c
818+
```
819+
820+
It is useful in conjunction with the -inum option.
821+
822+
```console
823+
$ trdsql -inum "SELECT * FROM test.text"
824+
1,a
825+
2,
826+
3,b
827+
4,
828+
5,c
829+
```
830+
831+
### 4.16. <a name='raw-output'></a>Raw output
796832

797833
`-oraw` is Raw Output.
798834
It is used when "escape processing is unnecessary" in CSV output.
@@ -817,7 +853,7 @@ $ trdsql -oraw -od "\t|\t" -db pdb "SELECT * FROM test.csv"
817853
3 | Apple
818854
```
819855

820-
### 4.16. <a name='ascii-table-&-markdown-output'></a>ASCII Table & MarkDown output
856+
### 4.17. <a name='ascii-table-&-markdown-output'></a>ASCII Table & MarkDown output
821857

822858
`-oat` is ASCII table output.
823859

@@ -845,7 +881,7 @@ $ trdsql -omd "SELECT * FROM test.csv"
845881

846882
The `-onowrap` option does not wrap long columns in `at` or `md` output.
847883

848-
### 4.17. <a name='vertical-format-output'></a>Vertical format output
884+
### 4.18. <a name='vertical-format-output'></a>Vertical format output
849885

850886
-ovf is Vertical format output("column name | value" vertically).
851887

reader.go

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var extToFormat map[string]Format = map[string]Format{
1818
"TSV": TSV,
1919
"PSV": PSV,
2020
"WIDTH": WIDTH,
21+
"TEXT": TEXT,
2122
}
2223

2324
// ReaderFunc is a function that creates a new Reader.

0 commit comments

Comments
 (0)