How can I use my Gmail contacts within Alpine/pine?

10

6

How can I use my Gmail contacts within Alpine/pine?

Ted

Posted 2009-10-14T04:30:37.610

Reputation:

Answers

4

An alternate way of importing your Google contacts is using pull_contacts.py.

This script will:

  1. perform a GData query to retrieve all the contacts; and
  2. print them in alpine's addressbook format.

So, to add all of your Google contacts to the addressbook, simply:

  python pull_contacts.py aphacker@gmail.com >> .addressbook

The main advantage of this method over the one described by DaveParillo is the added support for non-latin1 characters. If you're like me and have a lot of people with accented letters in their names, this script is a God-send -- you won't have to go through the list manually replacing ? with the right latin1 letter.

Note that the script requires the GData libraries.

scvalex

Posted 2009-10-14T04:30:37.610

Reputation: 141

Ah. I now use goobook, for what it's worth. It's an abook clone that uses Google contacts. – scvalex – 2012-02-08T10:37:19.427

2Doesn't work for me. It seems, since the last post made, gmail moved forward: gdata.service.RequestError: {'status': 301, 'body': '<HTML>\n<HEAD>\n<TITLE>Moved Permanently</TITLE>\n</HEAD>\n<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n<H1>Moved Permanently</H1>\nThe document has moved <A HREF="https://www.google.com/m8/feeds/contacts/default/full?max-results=1000">here</A>.\n</BODY>\n</HTML>\n', 'reason': 'Moved Permanently'} – Tankman六四 – 2014-06-09T06:20:34.900

2

You can use this short piece of PYTHON code to extract the relevant columns from the Google CSV (use Export.. on Google Contacts Website). It also takes care of the translation from UTF-16 to your ISO locale.

import io
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import csv

a=io.open("google.csv",'r',encoding="utf-16")
r=csv.reader(a,quotechar='"')
for b in r:
    if b[28] <> "":
        print "\t"+b[0]+"\t"+b[28]

Call it as in:

python google.py >~/.addressbook

Robert

Posted 2009-10-14T04:30:37.610

Reputation: 33

Getting this: Traceback (most recent call last): File "google.py", line 9, in <module> for b in r: File "/usr/lib/python2.7/codecs.py", line 314, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) File "/usr/lib/python2.7/encodings/utf_16.py", line 67, in _buffer_decode raise UnicodeError("UTF-16 stream does not start with BOM") UnicodeError: UTF-16 stream does not start with BOM – Regmi – 2019-01-28T04:25:29.717

2

I don't think you can just 'reach out' and use them on the fly, but you can append them to your existing ~/.addressbook

  1. in GMail, choose 'Contacts', then 'Export' in the upper right corner
  2. choose 'Outlook CSV' & save
  3. open it in a spreadsheet
  4. delete first line, insert a column before the others
  5. Save As -> Text export (configurable)
    • in the upcoming dialog choose:
    • Separator: Tab
    • Never Quote
  6. Save file
  7. append this file to your .addressbook-file.

    cat gmailfile.csv >> ~/.addressbook

DaveParillo

Posted 2009-10-14T04:30:37.610

Reputation: 13 402

1

I found a much easier method!

Go to your contacts in google, and copy the entire contacts (ie, two columns, with names in first, and address in second, leave the "Name" and "Details" row)

Now, go to your home folder, and unhide by Ctrl+h. Open the .addressbook file.

Simply paste and save.

Open your alpine, and check!


Most will not need the following step.

For formatting and aligning, you may first create one contact through alpine, and then open your addressbook file. you will see your entry. Then paste and separate through tab accordingly.

Pratik

Posted 2009-10-14T04:30:37.610

Reputation: 11

I can't figure out exactly how to select and copy the text as described, neither in the the "old" nor "new" interface. I might just be stupid, or this answer may no longer work. – Brian Z – 2015-11-08T02:23:56.450