Spero che questo script possa servire anche a qualcun'altro.
Non è molto che uso Ruby, ma sono sicuro che si può fare la stessa cosa in maniera più elegante e compatta..
Code: Select all
#! /usr/bin/ruby
=begin
vcf2csf - Export vcffile to csvfile
$Author: Assente $
Copyright (C) 2004 assente.altervista.org
This program is free software.
You can distribute/modify this program under
the terms of the GPL License.
=end
# CONFIG ME
vcfwords=["FN:","EMAIL;TYPE=WORK;X-EVOLUTION-UI-SLOT=1:","TEL;TYPE=CELL;X-EVOLUTION-UI-SLOT=3:"]
csvwords=["Full Name","Email Address","Mobile"]
#
if (ARGV[0]=="--help" || ARGV[0]==nil || ARGV[1]==nil)
puts "Usage: ./vcf2csf.rb [] []
Function: Convert a vcffile to csvfile, usefull to export contacts from Evolution to GMail"
else
vcffile=ARGV[0]
csvfile=ARGV[1]
csv=""
rows=open(vcffile).readlines
for i in 0..rows.length-1
if rows[i].slice(0,5)=='BEGIN'
csv << "\n"
end
for j in 0..vcfwords.length-1
if rows[i].slice(0,vcfwords[j].length)==vcfwords[j]
csv << rows[i].slice(vcfwords[j].length,30).chomp
csv << ","
end
end
end
c=open(csvfile,'w+');
c.write(csvwords.join(",")+csv)
c.close
end
