Skip to content

Commit 0317c5d

Browse files
committed
demo-case/filter-some-row
1 parent bbabe37 commit 0317c5d

38 files changed

+876
-0
lines changed

demo-case/filter-some-row/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
3+
## 相關討論串
4+
5+
* https://www.facebook.com/groups/ubuntu.zh.hant/permalink/2553986081323365/
6+
* https://www.facebook.com/groups/ubuntu.zh.hant/permalink/2486647224723918/
7+
8+
9+
## 專案
10+
11+
* [use-awk](use-awk)
12+
* [use-php-office](use-php-office)
13+
* [use-php-fputcsv](use-php-fputcsv)
14+
* [use-python-csv](use-python-csv)
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
3+
default: filter
4+
.PHONY: default
5+
6+
7+
help:
8+
@echo Usage:
9+
10+
@echo make
11+
@echo make help
12+
13+
@echo make to-csv
14+
@echo make filter
15+
@echo make to-ods
16+
17+
@echo make final-dump-csv
18+
@echo make final-view-ods
19+
@echo make final-view-csv
20+
21+
@echo make clean
22+
23+
24+
.PHONY: help
25+
26+
27+
filter: to-csv
28+
@./run.sh
29+
.PHONY: filter
30+
31+
32+
to-csv:
33+
@./to-csv.sh
34+
.PHONY: to-csv
35+
36+
37+
to-ods:
38+
@./to-ods.sh
39+
.PHONY: to-ods
40+
41+
42+
clean:
43+
rm -f ./var/*.csv
44+
rm -f ./var/*.ods
45+
.PHONY: clean
46+
47+
48+
final-view-csv:
49+
localc ./var/output.csv
50+
.PHONY: final-view-csv
51+
52+
53+
final-view-ods:
54+
localc ./var/output.ods
55+
.PHONY: final-view-ods
56+
57+
58+
final-dump-csv:
59+
@cat ./var/output.csv
60+
.PHONY: final-dump-csv
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
3+
## Howto
4+
5+
來源檔案放在「data」這個資料夾底下
6+
7+
執行
8+
9+
``` sh
10+
$ make
11+
```
12+
13+
產生的檔案放在「var」這個資料夾底下
14+
15+
16+
## 參考連結
17+
18+
* http://www.grymoire.com/Unix/Awk.html
19+
* http://wanggen.myweb.hinet.net/ach3/ach3.html?MywebPageId=2019131555151293536&MywebPageId=2019131555151299196#awk
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.~lock*
9.04 KB
Binary file not shown.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/awk -f
2+
BEGIN {
3+
## 用「,」拆解欄位
4+
FS=",";
5+
}
6+
{
7+
## 排除 第四個欄位是0的
8+
if ($4 != 0) {
9+
print $0
10+
#printf("%s,%s,%s,%s\n", $1, $2, $3, $4)
11+
}
12+
}
13+
END {
14+
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
## 一行的寫法
4+
awk -F ',' '{ if ($4 != 0) { print $0 } }' "var/input.csv" > "var/output.csv"
5+
6+
## 下面的寫法,將上面的寫法,寫在檔案「main.awk」,當成「Script」來使用
7+
#./main.awk var/input.csv > var/output.csv
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
./main.sh
4+
5+
./to-ods.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
#localc --headless --convert-to csv:"Text - txt - csv (StarCalc)":44,34,76,,,,true data/input.ods --outdir var
4+
5+
localc --headless --convert-to csv:"Text - txt - csv (StarCalc)":44,34,76,,,,true,,,true data/input.ods --outdir var
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
4+
## filter
5+
localc --headless --convert-to ods var/output.csv --outdir var
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.~lock*
2+
*.csv
3+
*.ods
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
3+
default: filter
4+
.PHONY: default
5+
6+
7+
help:
8+
@echo Usage:
9+
10+
@echo make
11+
@echo make help
12+
13+
@echo make to-csv
14+
@echo make filter
15+
@echo make to-ods
16+
17+
@echo make final-dump-csv
18+
@echo make final-view-ods
19+
@echo make final-view-csv
20+
21+
@echo make clean
22+
23+
24+
.PHONY: help
25+
26+
27+
filter: to-csv
28+
@./run.sh
29+
.PHONY: filter
30+
31+
32+
to-csv:
33+
@./to-csv.sh
34+
.PHONY: to-csv
35+
36+
37+
to-ods:
38+
@./to-ods.sh
39+
.PHONY: to-ods
40+
41+
42+
clean:
43+
rm -f ./var/*.csv
44+
rm -f ./var/*.ods
45+
.PHONY: clean
46+
47+
48+
final-view-csv:
49+
localc ./var/output.csv
50+
.PHONY: final-view-csv
51+
52+
53+
final-view-ods:
54+
localc ./var/output.ods
55+
.PHONY: final-view-ods
56+
57+
58+
final-dump-csv:
59+
@cat ./var/output.csv
60+
.PHONY: final-dump-csv
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
3+
## Howto
4+
5+
來源檔案放在「data」這個資料夾底下
6+
7+
執行
8+
9+
``` sh
10+
$ make
11+
```
12+
13+
產生的檔案放在「var」這個資料夾底下
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.~lock*
Binary file not shown.

0 commit comments

Comments
 (0)