将 CSV 联系人导入 Evolution 3.0.2

将 CSV 联系人导入 Evolution 3.0.2

我正在运行 Evolution 3.0.2(来自 Fedora 15 安装的堆栈)。我有一个包含一些联系人的 CSV 文件。该文件是在备份我的旧手机时由三星软件创建的。

如果我转到File-> Import...->Import a single file并选择我的文件,我将给出三个选项File Type

  1. Evolution CSV 或 Tab(.csv、.tab)
  2. Mozilla CSV 或 Tab(.csv、.tab)
  3. Outlook CSV 或选项卡(.csv、.tab)

我尝试使用所有三个选项进行导入,但似乎没有一个有效:目标位置未修改。

三星生成的文件非常冗长。这是它的第一行:

“姓氏”、“名字”、“显示名称”、“昵称”、“阅读姓名(姓氏)”、“阅读姓名(名字)”、“正式职称”、“公司名称”、“电话号码1 (类型)","电话号码 1 (号码)","电话号码 1 (热键)","电话号码 2 (类型)","电话号码 2 (号码)","电话号码 2 (热键)","电话号码 3 (类型)","电话号码 3 (号码)","电话号码 3 (热键)","电话号码 4 (类型)","电话号码 4 (号码)","电话号码 4 (热键)","电话号码 5 (类型)","电话号码 5 (号码)","电话号码 5 (热键)","电话号码 6 (类型)","电话号码 6 (号码)","电话号码 6 (热键)","电话号码 7 (类型)","电话号码7(号码)","电话号码7(热键)","电话号码8(类型)","电话号码8(号码)","电话号码8(热键)","电话号码9 (类型)","电话号码 9 (号码)","电话号码 9 (热键)","电话号码 10 (类型)","电话号码 10 (号码)","电话号码 10 (热键)","电话号码 11 (类型)","电话号码11(号码)","电话号码11(热键)","电话号码12(类型)","电话号码12(号码)","电话号码12(热键)","电话号码13 (类型)","电话号码13(号码)","电话号码13(热键)","电话号码14(类型)","电话号码14(号码)","电话号码14(热键)","电子邮件1(类型)","电子邮件 1 (地址)","电子邮件 2 (类型)","电子邮件 2 (地址)","电子邮件 3 (类型)","电子邮件 3 (地址)","电子邮件 4 (类型)","电子邮件 4 (地址) )","电子邮件5(类型)","电子邮件5(地址)","电子邮件6(类型)","电子邮件6(地址)","电子邮件7(类型)","电子邮件7(地址)","电子邮件8(类型) ","电子邮件8(地址)","电子邮件9(类型)","电子邮件9(地址)","电子邮件10(类型)","电子邮件10(地址)","网页1(类型)","网页1(地址) )","网页 2 (类型)","网页 2 (地址)","网页 3 (类型)","网页 3 (地址)","网页 4 (类型)","网页 4 (地址)" ,"网页 5(类型)","网页 5(地址)","网页 6(类型)","网页 6(地址)","网页 7(类型)","网页 7(地址)","网页 8(类型)"、"网页 8(地址)"、"网页 9(类型)"、"网页 9(地址)"、"网页 10(类型)"、"网页 10(地址)"、"Messenger1(类型)","Messenger1 (ID)","Messenger2 (类型)","Messenger2 (ID)","Messenger3 (类型)","Messenger3 (ID)","Messenger4 (类型)","Messenger4 (ID)","Messenger5 (类型)","Messenger5 (ID)","Messenger6 (类型)","Messenger6 (ID)"," Messenger7(类型)”、“Messenger7(ID)”、“Messenger8(类型)”、“Messenger8(ID)”、“Messenger9(类型)”、“Messenger9(ID)”、“Messenger10(类型)”、“Messenger10 (ID)","地址1(家庭/办公室)","地址1(国内/国外)","地址1(邮政信箱)","地址1(详细信息)","地址1(街道号码)","地址1(城市) /城镇)","地址1(县/地区)","地址1(国家)","地址1(邮政编码)","地址2(家庭/办公室)","地址2(国内/国外)","地址2(邮政信箱)框)”、“地址 2(详细信息)”、“地址 2(街道号码)”、“地址 2(城市/城镇)”、“地址 2(县/地区)”、“地址 2(国家)”、“地址 2(邮政编码)” ,"Address3(家庭/办公室)","Address3(国内/国外)","Address3(邮政信箱)","Address3(详细信息)","Address3(街道号码)","Address3(城市/城镇)" ,"地址3(县/地区)","地址3(国家)","地址3(邮政编码)","地址4(家庭/办公室)","地址4(国内/国外)","地址4(邮政信箱)", “地址4(详细信息)”、“地址4(街道号码)”、“地址4(城市/城镇)”、“地址4(县/地区)”、“地址4(国家)”、“地址4(邮政编码)”、“地址5(家庭/办公室)","地址 5 (国内/国外)","地址 5 (邮政信箱)","地址 5 (详细信息)","地址 5 (街道号码)","地址 5 (城市/城镇)","地址 5 (县/地区)”、“地址5(国家)”、“地址5(邮政编码)”、“地址6(家庭/办公室)”、“地址6(国内/国外)”、“地址6(邮政信箱)”、“地址6(详细信息) )","地址 6 (街道号码)","地址 6 (城市/城镇)","地址 6 (县/地区)","地址 6 (国家)","地址 6 (邮政编码)","地址 7 (家庭/办公室) ","Address7(国内/国外)","Address7(邮政信箱)","Address7(详细信息)","Address7(街道号码)","Address7(城市/城镇)","Address7(县/地区) ","Address7(国家/地区)","Address7(邮政编码)","Address8(家庭/办公室)","Address8(国内/国外)","Address8(邮政信箱)","Address8(详细信息)","地址 8(街道号码)"、"地址 8(城市/城镇)"、"地址 8(县/地区)"、"地址 8(国家)"、"地址 8(邮政编码)"、"地址 9(家庭/办公室)"、"地址 9 (国内/国外)","地址9(PO框)”、“地址 9(详细信息)”、“地址 9(街道号码)”、“地址 9(城市/城镇)”、“地址 9(县/地区)”、“地址 9(国家)”、“地址 9(邮政编码)” ,"Address10(家庭/办公室)","Address10(国内/国外)","Address10(邮政信箱)","Address10(详细信息)","Address10(街道号码)","Address10(城市/城镇)" ,"地址10(县/地区)","地址10(国家)","地址10(邮政编码)","生日(日期)","生日(阳历/农历)","周年纪念1(日期)","周年纪念1 (阳历/农历)”、“周年纪念2(日期)”、“周年纪念2(阳历/农历)”、“周年纪念3(日期)”、“周年纪念3(阳历/农历)”、“血型”、“爱好”、“铃声类型” ","铃声","消息铃声类型","消息铃声","照片文件","备忘录","语音识别","双机模式","标题","中间名","后缀" ,"部门","助理姓名","助理电话","经理","政府ID","账户","客户ID","办公地点","配偶","子女","类别", “附加信息”

我想进化论期望它以不同的形式出现。有人能指出 Evolution 期望这个文件是什么样的吗?然后我可以相应地调整它的列。或者以更直接的方式导入它,如果可能的话,

答案1

我对这个问题的解决方案是使用 Python csv 模块读取 csv,然后将数据转储为 vcard。一张电子名片可以包含多个联系人,只需附加它们即可。

剧本:

#!/usr/bin/python

# Read a Samsung backup csv and outputs a vcf file

import csv
import sys

def convert(filename):
    reader = csv.reader(open(filename, 'rb'))

    for row in reader:
        firstname = row[1]
        lastname = row[0]
        telephone = row[9]

        print 'BEGIN:VCARD'
        print 'VERSION:2.1'
        print 'N:' + lastname + ';' + firstname
        print 'FN:' + firstname + ' ' + lastname
        print 'TEL;HOME;VOICE:' + telephone
        print 'END:VCARD'

def main(args=sys.argv):
    if len(args) != 2:
        print "Usage:"
        print args[0] + " filename"
        return 1

    convert(args[1])
    return 0

if __name__ == '__main__':
    sys.exit(main())

用法如下:

./script.py myfile.csv > mycontacts.vcf 

然后将生成的vcf文件导入到Evolution中。丑陋,但有效。

答案2

因为我在搜索时多次偶然发现这个问题:这里是一个更新且稍作修改的版本维托·皮斯的回答适用于 Python 3。已使用版本 3.10 进行测试

#!/usr/bin/python

import csv
import sys

def convert(filename):
    f_csv = csv.reader(open(filename, 'r'), delimiter=",")
    f_vcard = open(f'vcard_{filename.split(".")[0]}.vcard', 'w+')

    for row in f_csv:
        firstname = row[1]
        lastname = row[2]
        birthday = row[3]
        mail = row[4]
        telephone = row[5]

        f_vcard.write('BEGIN:VCARD\n')
        f_vcard.write('VERSION:3.0\n')
        f_vcard.write(f'N:{lastname};{firstname}\n')
        f_vcard.write(f'FN:{firstname} {lastname}\n')
        f_vcard.write(f'TEL;TYPE=CELL;VOICE:{telephone}\n')
        f_vcard.write(f'EMAIL;TYPE=OTHER:{mail}\n')
        f_vcard.write(f'END:VCARD\n')

    f_vcard.close()

def main(args=sys.argv):
    if len(args) != 2:
        print("Usage:")
        print(f"{args[0]} filename")
        return 1

    convert(args[1])
    return 0

if __name__ == '__main__':
    sys.exit(main())

相关内容