Skip to content

Commit

Permalink
Add extension support for text format
Browse files Browse the repository at this point in the history
Add support for determining text format by extension.
Add text format description to README.md.
  • Loading branch information
noborus committed Oct 27, 2024
1 parent 11af483 commit 112140c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ trdsql -o[output format] -t [input filename]
* `-iyaml` YAML format for input.
* `-itbln` TBLN format for input.
* `-iwidth` width specification format for input.
* `-itext` text format for input.

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

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

Expand Down Expand Up @@ -792,6 +794,39 @@ But `-id " "` does not recognize spaces in columns very well.

`-iwidth` recognizes column widths and space separators.

### TEXT

The `-itext` option or files with “.text”extension are in text format.

This is a one line to one column format.
A blank line is also a line, unlike the `CSV` format.

```console
$ cat test.text
a

b

c
$ trdsql -itext "SELECT * FROM test.text"
a

b

c
```

It is useful in conjunction with the -inum option.

```console
$ trdsql -inum "SELECT * FROM test.text"
1,a
2,
3,b
4,
5,c
```

### 4.15. <a name='raw-output'></a>Raw output

`-oraw` is Raw Output.
Expand Down
1 change: 1 addition & 0 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var extToFormat map[string]Format = map[string]Format{
"TSV": TSV,
"PSV": PSV,
"WIDTH": WIDTH,
"TEXT": TEXT,
}

// ReaderFunc is a function that creates a new Reader.
Expand Down

0 comments on commit 112140c

Please sign in to comment.