Skip to content
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

Feature/rfc 4180 #39

Merged
merged 29 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5a3006e
Remove leading white spaces
greymd Feb 20, 2023
81ccd5b
Add basic csv module files
greymd Feb 21, 2023
3856eac
Accept --csv long option
greymd Feb 21, 2023
ac7d4a4
Refactoring
greymd Feb 21, 2023
f22c723
--csv prototype
greymd Feb 22, 2023
ec17d04
--csv: Include quote
greymd Feb 22, 2023
59d5c1c
CSV parser works minimum
greymd Feb 23, 2023
806c896
New lines are separated into multi chunks
greymd Feb 25, 2023
1a0a89f
CSV tests for newline/comma/quotations
greymd Feb 25, 2023
12b46b0
Update debug message
greymd Feb 25, 2023
dfc79a5
CSV test for CRLF
greymd Feb 25, 2023
1c036ac
Refactoring
greymd Feb 25, 2023
3686980
Make CSV Parser compact
greymd Feb 25, 2023
1988031
Change behavior of -s and --csv
greymd Feb 26, 2023
2aa840a
--chomp option
greymd Feb 26, 2023
affeaa1
Add test for long line more than 10KB
greymd Feb 26, 2023
37c02fb
Benchmarking for CSV
greymd Feb 26, 2023
67531d4
Remove noisy debug message
greymd Feb 26, 2023
6b5a45e
Use perl for tests which include multi-byte chars
greymd Feb 26, 2023
d85685f
Use sed supporting UTF-8
greymd Feb 26, 2023
3a9ccb7
Fix test_win.yml
greymd Feb 26, 2023
0115c95
Overwrite sed.exe
greymd Feb 26, 2023
b568c8d
Move-Item -Force sed.exe
greymd Feb 26, 2023
5237fb8
Revert some tests
greymd Feb 26, 2023
917afe2
Do not run UTF-8 related test on Windows
greymd Feb 26, 2023
0c38e7e
[skip] Update --help explanation
greymd Feb 26, 2023
d0612fd
Fix test_{,solid}csv_non_delim_comma tests
greymd Feb 26, 2023
0f44de4
[skip] Add --csv description to --help and README
greymd Feb 26, 2023
ada4c2e
[skip] Update README.md
greymd Feb 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
cmd: teip -Gog '.*sshd' < test_secure
- name: convert_date
cmd: teip -c1-15 -- date -f- +%s < test_secure
- name: csv
cmd: teip --csv -f 2 -- tr '[:print:]' '@' < test.csv
# same as: awk '{gsub(".","@",$2);print}' FS=, OFS=, < test.csv

steps:
- uses: actions/checkout@v2

Expand All @@ -57,6 +61,8 @@ jobs:
sudo dpkg -i ./hyperfine_1.9.0_amd64.deb
wget https://github.com/greymd/test_files/raw/v1.0.0/logs/test_secure.gz
gzip -d ./test_secure.gz
wget https://github.com/greymd/test_files/raw/v1.0.0/xsv/1000000_Sales_Records.csv.gz
zcat 1000000_Sales_Records.csv.gz | awk '{print}' > test.csv # Filtered by AWK to add trailing newline

- name: Benchmark for a large file
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ jobs:
run: |
cargo test --verbose --features oniguruma
bash tests/test_large_file.sh
bash tests/test_long_line.sh
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "teip"
version = "2.0.0"
version = "2.1.0-beta"
authors = ["Yasuhiro Yamada <[email protected]>"]
description = "Highly efficient \"Masking tape\" for standard input"
keywords = ["sed", "awk", "util"]
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@
<img src="https://raw.githubusercontent.com/wiki/greymd/teip/img/teip_intro.png" alt="Git Animation for Introduction" width="50%" />
</p>

* Edit 4th and 6th columns in the CSV file
* Replace 'WORLD' to 'EARTH' on line including 'HELLO'

```bash
$ cat file.csv | teip -d, -f 4,6 -- sed 's/./@/g'
$ cat file | teip -g HELLO -- sed 's/WORLD/EARTH/'
```

* Edit 2nd column in the CSV file:

```bash
$ cat file.csv | teip --csv -f 2 -- sed 's/./@/g'
```

* Edit 2nd, 3rd and 4th fields on '|' separated file

```bash
$ cat file | teip -d '|' -f 2-4 -- sed 's/./@/g'
```

* Convert timestamps in /var/log/secure to UNIX time
Expand Down
2 changes: 1 addition & 1 deletion man/man.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ EXAMPLES
Edit 2nd, 3rd, and 4th columns in the CSV file

```
$ cat file.csv | teip -f 2-4 -d , -- sed 's/./@/g'
$ cat file.csv | teip --csv -f 2-4 -- sed 's/./@/g'
```

Convert timestamps in /var/log/secure to UNIX time
Expand Down
5 changes: 5 additions & 0 deletions src/csv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# csv submodule for teip

This is a submodule for the [teip](https://github.com/greymd/teip).
Many part of this module is based on [csv-core](https://github.com/BurntSushi/rust-csv/tree/master/csv-core).
which is dual-licensed under MIT and Unlicense as of 2023-02-21
Loading