<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- <base href = "http://localhost/~ckhung/"> -->

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 6 November 2007), see www.w3.org" />
  <?php include "../../i/meta.en.php" ?>

  <title>vcf2csv and csv2vcf: Converting Android Address Book to and
  from a Spreadsheet File</title>
</head>

<body>
  <?php include "../../i/header.en.php" ?>

  <div id="content">
    <h1>vcf2csv and csv2vcf: Converting Android Address Book to and
    from a Spreadsheet File</h1>

    <p>(<a href="index.zh_TW.php">中文版</a>)</p>

    <p>I am glad that my wife bought an HTC Aria (running Android) and
    not an iPhone. So I decided it's worth my time to help her
    importing her addressbook from a spreadsheet file into her new
    smart phone. I am sharing three small scripts here so that it's
    easier for people to convert back and forth between the Android
    address book file format .vcf and the simple format .csv, which can
    be more easily edited using a spread sheet program on a computer.
    For the impatient: uncompress <a href="download.php">the
    snapshot</a> and on a linux computer you can:</p>

    <ol>
      <li>generate an editable file: <code>./qp28bit &lt; contacts.vcf
      | ./vcf2csv &gt; editable.csv</code></li>

      <li>edit editable.csv using oocalc or gnumeric</li>

      <li>convert it back for Android to import: <code>./csv2vcf &lt;
      editable.csv &gt; new-contacts.vcf</code></li>
    </ol>

    <p>Here are the details:</p>

    <ol>
      <li><a href="qp28bit">qp28bit</a> replaces each quoted-printable
      encoded string (which may span multiple lines) in a .vcf file
      with 8-bit characters that fits into one line. For example,
      <code>./qp28bit <a href="contacts.vcf">contacts.vcf</a> &gt;
      contacts-8bit.vcf</code> decodes the quoted-printable strings
      into a new contact file contacts-8bit.vcf so that the utf-8
      encoded Chinese characters are readable and editable using any
      plain text editor. Sometimes I have to apply this more than once
      to a vcf file exported by Android.</li>

      <li><a href="vcf2csv">vcf2csv</a> converts a .vcf file
      <em>containing no multiple-line fields</em> into a spread sheet
      file. More precisely, (1) it is supposed to process a .vcf file
      generated by qp28bit, and (2) <em>the PHOTO field is silently
      dropped!</em> For example, <code>./vcf2csv <a href=
      "contacts-8bit.vcf">contacts-8bit.vcf</a> &gt;
      editable.csv</code> converts contacts-8bit.vcf into editable.csv,
      which can be imported into calc (spreadsheet program of OO.o). It
      accepts the -d option to specify a delimiter other than "," the
      default delimiter. For example: <code>./csv2vcf -d '#'
      contacts.vcf &gt; editable.csv</code> creates a csv file
      delimited by hash marks instead of commas.</li>

      <li><a href="csv2vcf">csv2vcf</a> converts a spread sheet file
      into an Android address book. For example, <code>./csv2vcf
      <a href="editable.csv">editable.csv</a> &gt;
      new-contacts.vcf</code> converts editable.csv into
      new-contacts.vcf . It also accepts the -d option to specify a
      delimiter other than ",".</li>
    </ol>

    <p>These scripts are short and crude, meaning that many assumptions
    are made about the files, and that there is hardly any error
    checking. Specifically:</p>

    <ol>
      <li>Quotes are not processed. This implies that you cannot have
      commas in your data, or if you do, you will have to use a
      delimiter other than comma.</li>

      <li>Contents in an input file (to any of the 3 scripts) are
      assumed to use the utf8 charset. You can see this assumption
      explicitly in the code of qp28bit. You may have to pre-process
      the csv file using iconv if your spread sheet program exports csv
      files in other encodings (big5, gb2312, ... for example).</li>

      <li>csv2vcs uses 8-bit encoding instead of the original
      and more elaborate quoted-printable encoding. Anyway it
      seems acceptable to Android.</li>

      <li>For all scripts, the ouput files uses Linux style newlines --
      a newline is one bye (LF) instead of two bytes (CR, LF).</li>
    </ol>

    <p>Well, excel can also read/write csv files. But please give OO.o
    a try next time, ok?</p>

    <h2>Notes for other Smart Phones and Applications</h2>

    <p>Different contact managers/address book programs may use
    slightly different names for the same field. Here is a list of
    string substitutions to make for smart phones/applications that I
    happen to have played with.</p>

    <ol>
      <li>For gmail to import the vcf file, you have to change all
      "EMAIL;INTERNET" to "EMAIL;HOME", like <a href=
      "gmail.vcf">this</a>.</li>

      <li>For zimbra to import the csv file, you need to use following
      field names: "firstName", "lastName", "fullName", "homePhone",
      "mobilePhone", "workPhone", "email", "email2",... like <a href=
      "zimbra.csv">this</a>.</li>
    </ol>

    <h2>Comments?</h2>

    <p>I have no energy to maintain a full-blown software package and
    its corresponding maintainence system. However, your comments are
    most welcome. Please use <a href=
    "http://newtoypia.blogspot.com/2010/08/vcf2csv-csv2vcf-android.html">
    this blog entry</a> to leave your comments.</p>

    <h2>History</h2>

    <ul>
      <li>2011/02/07: Complete re-write as 3 modular commands to
      replace the original 2 messy and buggy commands.</li>

      <li>2010/08/18: First release</li>
    </ul><?php include "footer.en.php" ?>
  </div><?php include "$top[fs]/i/navigator.en.php" ?>
</body>
</html>
