Skip to content

Commit ea98d3c

Browse files
committed
demo-case/filter-some-row/use-python-pandas
1 parent 0317c5d commit ea98d3c

File tree

10 files changed

+117
-0
lines changed

10 files changed

+117
-0
lines changed
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,18 @@
1+
2+
3+
## Howto
4+
5+
來源檔案放在「data」這個資料夾底下
6+
7+
執行
8+
9+
``` sh
10+
$ make
11+
```
12+
13+
產生的檔案放在「var」這個資料夾底下
14+
15+
16+
## 參考連結
17+
18+
* https://www.facebook.com/groups/ubuntu.zh.hant/permalink/2553986081323365/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.~lock*
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env python3
2+
3+
## 來自討論串 https://www.facebook.com/groups/ubuntu.zh.hant/permalink/2553986081323365/
4+
## 使用前先安裝
5+
## sudo apt-get install python3-pandas
6+
7+
import pandas as pd
8+
9+
df = pd.read_csv("var/input.csv")
10+
df[df.bal != 0].to_csv("var/output.csv", index=False)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
## 來自討論串 https://www.facebook.com/groups/ubuntu.zh.hant/permalink/2553986081323365/
4+
## 使用前先安裝
5+
## sudo apt-get install python3-pandas
6+
## 一行的寫法
7+
python3 -c 'import pandas as pd;df = pd.read_csv("var/input.csv");df[df.bal != 0].to_csv("var/output.csv", index=False)'
8+
9+
## 下面的寫法,將上面的寫法,寫在檔案「main.awk」,當成「Script」來使用
10+
#./main.awk var/input.csv > var/output.csv
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

0 commit comments

Comments
 (0)