-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
trdsql: add page #14896
trdsql: add page #14896
Conversation
pages/common/trdsql.md
Outdated
> More information: <https://noborus.github.io/trdsql/>. | ||
> See also: `yq`, `jq` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> More information: <https://noborus.github.io/trdsql/>. | |
> See also: `yq`, `jq` | |
> See also: `yq`, and `jq`. | |
> More information: <https://noborus.github.io/trdsql/>. |
pages/common/trdsql.md
Outdated
|
||
- Convert array data from a JSON file to a CSV file (with double quote): | ||
|
||
`trdsql -ocsv "SELECT * FROM example.json" | sed 's/\([^,]*\)/"&"/g' > example.csv` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`trdsql -ocsv "SELECT * FROM example.json" | sed 's/\([^,]*\)/"&"/g' > example.csv` | |
`trdsql -ocsv "SELECT * FROM example.json" | sed 's/\([^,]*\)/"&"/g' > {{path/to/file.csv}}` |
pages/common/trdsql.md
Outdated
|
||
- Convert object data from multiple JSON files to a CSV file (with double quote): | ||
|
||
`trdsql -ocsv "SELECT * FROM example/*.json" | sed 's/\([^,]*\)/"&"/g' > example.csv` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`trdsql -ocsv "SELECT * FROM example/*.json" | sed 's/\([^,]*\)/"&"/g' > example.csv` | |
`trdsql -ocsv "SELECT * FROM example/*.json" | sed 's/\([^,]*\)/"&"/g' > {{path/to/file.csv}}` |
pages/common/trdsql.md
Outdated
|
||
- Cross join 2 csv files: | ||
|
||
`trdsql "SELECT * FROM a.csv CROSS JOIN b.csv"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`trdsql "SELECT * FROM a.csv CROSS JOIN b.csv"` | |
`trdsql "SELECT * FROM {{path/to/file1.csv}} CROSS JOIN {{path/to/file2.csv}}"` |
pages/common/trdsql.md
Outdated
|
||
- Create table data to MySQL database from CSV file: | ||
|
||
`trdsql -driver mysql -dsn "noborus:noborus@/trdsql_test" -ih "CREATE TABLE fruits (num int, name varchar(20)) AS SELECT id AS num,name FROM header.csv"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`trdsql -driver mysql -dsn "noborus:noborus@/trdsql_test" -ih "CREATE TABLE fruits (num int, name varchar(20)) AS SELECT id AS num,name FROM header.csv"` | |
`trdsql -driver mysql -dsn "noborus:noborus@/trdsql_test" -ih "CREATE TABLE fruits (num int, name varchar(20)) AS SELECT id AS num,name FROM {{path/to/file.csv}}"` |
pages/common/trdsql.md
Outdated
|
||
- Simple showing data from compress log files: | ||
|
||
`trdsql -iltsv "SELECT * FROM access.log.2.gz"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`trdsql -iltsv "SELECT * FROM access.log.2.gz"` | |
`trdsql -iltsv "SELECT * FROM {{path/to/access.log.gz}}"` |
Updated all the suggestions |
The build for this PR failed with the following error(s):
Please fix the error(s) and push again. |
pages/common/trdsql.md
Outdated
@@ -0,0 +1,32 @@ | |||
# trdsql | |||
|
|||
> CLI tool that executes SQL on CSV, LTSV, JSON, YAML, TBLN files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> CLI tool that executes SQL on CSV, LTSV, JSON, YAML, TBLN files. | |
> CLI tool that executes SQL on CSV, LTSV, JSON, YAML, and TBLN files. |
pages/common/trdsql.md
Outdated
|
||
- Convert object data from multiple JSON files to a CSV file with header (`-oh`) & double quote: | ||
|
||
`trdsql -ocsv -oh "SELECT * FROM {{path/to/file/*.json}}" | sed 's/\([^,]*\)/"&"/g' > {{path/to/file.csv}}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`trdsql -ocsv -oh "SELECT * FROM {{path/to/file/*.json}}" | sed 's/\([^,]*\)/"&"/g' > {{path/to/file.csv}}` | |
`trdsql -ocsv -oh "SELECT * FROM {{path/to/file/*.json}}" | sed 's/\([^,]*\)/"&"/g' > {{path/to/file.csv}}` |
pages/common/trdsql.md
Outdated
|
||
- Merge content of 2 CSV files to one CSV file: | ||
|
||
`trdsql "SELECT column1, colum2 FROM {{path/to/file1.csv}} UNION SELECT column1,column2 FROM {{path/to/file2.csv}}"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`trdsql "SELECT column1, colum2 FROM {{path/to/file1.csv}} UNION SELECT column1,column2 FROM {{path/to/file2.csv}}"` | |
`trdsql "SELECT {{column1,colum2}} FROM {{path/to/file1.csv}} UNION SELECT {{column1,column2}} FROM {{path/to/file2.csv}}"` |
pages/common/trdsql.md
Outdated
|
||
- Complex SQL data manipulation with multiple CSV files with first line is header (`-ih`): | ||
|
||
`trdsql -icsv -ih "SELECT id,name,phone_number FROM {{path/to/file*.csv}} WHERE phone_number != '' ORDER BY id GROUP BY field1"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`trdsql -icsv -ih "SELECT id,name,phone_number FROM {{path/to/file*.csv}} WHERE phone_number != '' ORDER BY id GROUP BY field1"` | |
`trdsql -icsv -ih "{{SELECT id,name,phone_number FROM {{path/to/file*.csv}} WHERE phone_number != '' ORDER BY id GROUP BY field1}}"` |
Can you please convert all examples to be in imperative mood? See style guide |
Co-authored-by: Wiktor Perskawiec <[email protected]>
I just updated, please review |
pages/common/trdsql.md
Outdated
|
||
`trdsql "SELECT * FROM {{path/to/file.json}}::.list` | ||
|
||
- Complex SQL data manipulation with multiple CSV files with first line is header (`-ih`): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Complex SQL data manipulation with multiple CSV files with first line is header (`-ih`): | |
- Manipulate Complex SQL data with multiple CSV files with first line is header (`-ih`): |
pages/common/trdsql.md
Outdated
|
||
`trdsql "SELECT {{column1,colum2}} FROM {{path/to/file1.csv}} UNION SELECT {{column1,column2}} FROM {{path/to/file2.csv}}"` | ||
|
||
- Simple connection to PostgreSQL database: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Simple connection to PostgreSQL database: | |
- Connect to PostgreSQL database: |
pages/common/trdsql.md
Outdated
|
||
`trdsql -driver mysql -dsn "noborus:noborus@/trdsql_test" -ih "CREATE TABLE {{table}} ({{column1}} int, {{colum2}} varchar(20)) AS SELECT {{column3}} AS {{column1}},{{column2}} FROM {{path/to/header_file.csv}}"` | ||
|
||
- Simple showing data from compress log files: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Simple showing data from compress log files: | |
- Show data from compress log files: |
pages/common/trdsql.md
Outdated
|
||
- Create table data to MySQL database from CSV file: | ||
|
||
`trdsql -driver mysql -dsn "noborus:noborus@/trdsql_test" -ih "CREATE TABLE {{table}} ({{column1}} int, {{colum2}} varchar(20)) AS SELECT {{column3}} AS {{column1}},{{column2}} FROM {{path/to/header_file.csv}}"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the -dsn parameter is a placeholder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, two sggestions
pages/common/trdsql.md
Outdated
> Execute SQL on CSV, LTSV, JSON, YAML, and TBLN files. | ||
> More information: <https://noborus.github.io/trdsql/>. | ||
|
||
- Convert object data from multiple JSON files to a CSV file with header (`-oh`) & double quote: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Convert object data from multiple JSON files to a CSV file with header (`-oh`) & double quote: | |
- Convert object data from multiple JSON files to a CSV file with header (`-oh`) and double quote: |
pages/common/trdsql.md
Outdated
|
||
`trdsql -ocsv -oh "SELECT * FROM {{path/to/file/*.json}}" | sed 's/\([^,]*\)/"&"/g' > {{path/to/file.csv}}` | ||
|
||
- Interpret JSON list as a table & put object inside as columns (path/to/file.json: `{"list":[{"age":"26","name":"Tanaka"}]}`): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Interpret JSON list as a table & put object inside as columns (path/to/file.json: `{"list":[{"age":"26","name":"Tanaka"}]}`): | |
- Interpret JSON list as a table and put objects inside as columns (path/to/file.json: `{"list":[{"age":"26","name":"Tanaka"}]}`): |
Thank you for your comments, I just fixed, please tag me if there are somethings that need to change. |
common
,linux
,osx
,windows
,sunos
,android
, etc.