UnK*_*OWn 6 bash scripts libreoffice
我正在使用 Ubuntu 20.04.1
我有 Libre Office Calc。有两列工作。
我每周都会编辑这两列一次..
A 987654320
B 987654321
C 987654322
D 987654323
E 987654324
F 987654325
G 987654326
Run Code Online (Sandbox Code Playgroud)
我需要编写一个 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
Run Code Online (Sandbox Code Playgroud)
我们可以通过两步过程得到所需的结果:
我们将电子表格转换为file.txt(真正的 CSV):
localc --headless --convert-to txt:"Text - txt - csv (StarCalc)" file.ods
Run Code Online (Sandbox Code Playgroud)
使用一些 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
Run Code Online (Sandbox Code Playgroud)