Libre Office Calcからデータを取得し、bashスクリプトで使用するにはどうすればよいですか?
Aug 22 2020
Ubuntu20.04.1を使用しています
Libre OfficeCalcを持っています。2つの列が機能しています。
私はこれらの2つの列を毎週1回編集します。
A 987654320
B 987654321
C 987654322
D 987654323
E 987654324
F 987654325
G 987654326
上記の2つの列からデータを取得し、例として以下のようなテキストファイルを作成するbashスクリプトを作成する必要があります。
BEGIN:VCARD
VERSION:3.0
FN:$(content of column1, row1) N:$(content of column1,row1)
TEL;TYPE=cell:$(content of column2, row1) END:VCARD BEGIN:VCARD VERSION:3.0 FN:$(content of column1, row2)
N:$(content of column1,row2) TEL;TYPE=cell:$(content of column2, row2)
END:VCARD
and so on till it finds the content at last existing row
回答
6 N0rbert Aug 22 2020 at 19:35
2段階のプロセスで必要な結果を得ることができます。
スプレッドシートをfile.txt(実際にはCSV)に変換します。
localc --headless --convert-to txt:"Text - txt - csv (StarCalc)" file.ods
いくつかのAWKスクリプトを使用します。
awk -F, '{ print "BEGIN:VCARD" print "VERSION:3.0" print "FN:"$1 print "N:"$1 print "TEL;TYPE=cell:"$2 print "END:VCARD" print "" }' file.txt