mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-24 10:52:52 +00:00
142 lines
4.3 KiB
CSV
142 lines
4.3 KiB
CSV
The CSV input and output format filters are based on KAddressBook CSV templates.
|
|
|
|
The most convenient way to create such a template is using KAddressBook, but as
|
|
they are quite simple structured files they can be written manually as well.
|
|
|
|
A CSV template is basically an INI-style text file with the .desktop file
|
|
extension.
|
|
|
|
The file consists of three sections:
|
|
|
|
General: describes formatting options, like how dates should be interpreted
|
|
or formatted, or what character is used as the field delimiter
|
|
|
|
Misc: Name of the template
|
|
|
|
csv column map: Describes which field or column of the CSV data has
|
|
which addressbook field.
|
|
|
|
kabcclient finds template files in its current working directory and the
|
|
csv-template subdirectories of KAddressBook's data locations.
|
|
|
|
Available templates can be listed using help as the csv filters option
|
|
|
|
#> kabcclient -if csv -if-opts help
|
|
or
|
|
#> kabcclient -of csv -of-opts help
|
|
|
|
Using for example the kaddressbook template installed with KAddressBook
|
|
would look like this
|
|
#> kabcclient -if csv -if-opts kaddressbook
|
|
or
|
|
#> kabcclient -of csv -of-opts kaddressbook
|
|
|
|
Example:
|
|
--------- csvexample.desktop -------
|
|
[General]
|
|
Columns=3
|
|
DatePattern=Y-M-D
|
|
DelimiterType=0
|
|
QuoteType=0
|
|
|
|
[Misc]
|
|
Name=Example CSV template
|
|
|
|
[csv column map]
|
|
0=1
|
|
1=2
|
|
2=7
|
|
------------------------------------
|
|
This would transform the following input
|
|
"Doe","John","2005-07-25"
|
|
into an addressbook entry for a person named John Doe, having been born on
|
|
July 25th, 2005
|
|
|
|
Quotes can be omitted if the field's value does not contain the separator
|
|
character, e.g Doe,John,2005-07-25 would be a valid input as well
|
|
(no comma in any of the three fields)
|
|
|
|
Details:
|
|
|
|
Columns=3 says that the CSV data will have three fields.
|
|
DatePattern=Y-M-D says that dates are to be interpreted as four digit year
|
|
followed by two digit month followed by a two digit day,
|
|
separated by '-'
|
|
Other possible letters are y (two digit year using 19 as
|
|
the century), m (one digit month for months < 10) and
|
|
d (one digit day for days < 10)
|
|
|
|
DelimiterType=0 use comma as the field separator. Other possible values are:
|
|
1 (semicolon), 2 (tab), 3 (single space), 4 (user defined)
|
|
In case of DelimiterType=4 there is an additional entry
|
|
DelimiterOther which has the separator character as its
|
|
value.
|
|
|
|
DelimiterType=4 followed by DelimiterOther=, would for
|
|
example be equivalent to DelimiterType=0
|
|
|
|
QuoteType=0 use standard double quote character " as the possible field
|
|
quoting. Other possible values are: 1 (use single quote '),
|
|
2 no quoting.
|
|
|
|
The CSV output format filter uses the specified quote character
|
|
on all fields.
|
|
|
|
The column map tells the filters which columns of the CSV data maps to which
|
|
field in the address book. Column index starts at 0.
|
|
The above example template says that the first column is the family name, the
|
|
second column is the given name or first name and that the thrid and last columns
|
|
is the birthday date.
|
|
|
|
For full examples see the files installed along KAddressBook.
|
|
|
|
--- field names and their csv column map values -----
|
|
|
|
00 "Formatted Name"
|
|
01 "Family Name"
|
|
02 "Given Name"
|
|
03 "Additional Names"
|
|
04 "Honorific Prefixes"
|
|
05 "Honorific Suffixes"
|
|
06 "Nick Name"
|
|
07 "Birthday"
|
|
08 "Home Address Street"
|
|
09 "Home Address Locality"
|
|
10 "Home Address Region"
|
|
11 "Home Address Postal Code"
|
|
12 "Home Address Country"
|
|
13 "Home Address Label"
|
|
14 "Business Address Street"
|
|
15 "Business Address Locality"
|
|
16 "Business Address Region"
|
|
17 "Business Address Postal Code"
|
|
18 "Business Address Country"
|
|
19 "Business Address Label"
|
|
20 "Home Phone"
|
|
21 "Business Phone"
|
|
22 "Mobile Phone"
|
|
23 "Home Fax"
|
|
24 "Business Fax"
|
|
25 "Car Phone"
|
|
26 "Isdn"
|
|
27 "Pager"
|
|
28 "Email Address"
|
|
29 "Mail Client"
|
|
30 "Title"
|
|
31 "Role"
|
|
32 "Organization"
|
|
33 "Note"
|
|
34 "URL"
|
|
|
|
// values below currently not supported by kabcclient's filters
|
|
|
|
35 "Department"
|
|
36 "Profession"
|
|
37 "Assistant's Name"
|
|
38 "Manager's Name"
|
|
39 "Spouse's Name"
|
|
40 "Office"
|
|
41 "IM Address"
|
|
42 "Anniversary"
|
|
-----------------------------------------
|
|
|