|
PHP, Act! Contact Mgt. & Pocket Organizers
Today, my project was to get 1,300 addresses out of Act! Contact Management and into an inexpensive Sharp Electronic Organizer (which can probably hold 13,000 addresses, and runs for a long time on a single AAA battery.)
In the coming weeks, I hope to post some of what I have done in PHP to emulate the some of the functionality of Act! Contact Management.
It astounded me when my PHP MySQL system ran faster from a website, than my Act! does on a new Dell Windows XP (Home Edition).
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Sharp Organizer Import from Act! Contact Management csv export</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="generator" content="HAPedit 3.0"> </head> <body bgcolor="#FFFFFF"> <? // Your code here /* Here is the header which the Sharp Organizer exports as the first record of a csv export Therefore, it must be the first record of a csv import file. "Category","Last Name","First Name","Company","Home#","Office#","Fax#","Mobile#","Pager#","Address","E-mail","Note" */ $Header_Rec = '"Category","Last Name","First Name","Company","Home#","Office#","Fax#","Mobile#","Pager#","Address","E-mail","Note"'; /* I have chosen to output all records to the Sharp Pocket Organizer with a Category of "Others" for the simple reason that, it is the default category, and all records will show automatically. Only two other Categories are available (to my knowledge), namely Business and Personal, */ $Category = "Others"; echo $Header_Rec; $fileinname = "actexport.txt"; $filein = fopen($fileinname, "r") or die("could not open $fileinname"); $fileoutname = "sharpimport.txt"; $fileout = fopen($fileoutname, "w") or die("could not open $fileoutname"); // Very important! Write out the header as the first record, otherwise the Sharp // Organizer will spin its wheels for 10 minutes and then tell you that no // records were found! fputs($fileout, "$Header_Rec\n"); $record_count = 0;
while (!feof($filein)) { $line = fgets($filein, 1024) ; // Because I choose to explode the line using ' "," ' as delimeter, // the first field, Company, and the last field, Suffix, will have // a double quote appended, but then I need to re-quote the fields // for output anyway. Remember, if I were to just use comma " , " // that there are street and company fields which contain commas. $a = explode('","', $line); $c = 0; $Last_Name = ""; $First_Name = ""; $Company = ""; $Home_Number = ""; $Office_Number = ""; $Fax_Number = ""; $Mobile_Number = ""; $Pager_Number = ""; $Address = ""; $E_Mail = ""; $Note = "";
foreach($a as $field) { $c = $c + 1; echo "$c: $field<br>"; } $Last_Name = $a[11]; $First_Name = $a[10]; // Remember! The very first element of a PHP array is not ONE but ZERO! // So, Company is the ZEROETH element of $a array. $Company = $a[0]; // I dont happen to use this field at work $Home_Number = $a[12]; $Office_Number = $a[6]; $Fax_Number = $a[7]; // $Mobile_Number = $a[12]; //$Pager_Number = $a[12];
// The next line, which concatenates Street, City, State and Zip // into one field, Address, is the main motive for me to write a PHP // script to reformat // Act! Contact Management has an export function, but it can only // export Street, City, State and Zip as separate fields. There is // no way to concatenate them without writing a program. And the // Sharp Organizer only provides one long field for the entire address // of Street, City, State and Zip $Address = $a[2] . "/" . $a[3] . " " . $a[4] . " " . $a[5]; $E_Mail = $a[15]; // $Note = ""; /* Header "Category","Last Name","First Name","Company","Home#","Office#","Fax#","Mobile#","Pager#","Address","E-mail","Note" */ echo "Category = $Category<br>"; echo "Last Name : $Last_Name <br> "; echo "First Name : $First_Name <br>"; echo "Company : $Company <br>"; echo "Home : $Home_Number <br>"; echo "Office: $Office_Number <br>"; echo "Fax: $Fax_Number <br>"; echo "Mobile : $Mobile_Number <br>"; echo "Pager: $Pager_Number <br>"; echo "Address: $Address <br>"; echo "E-Mail: $E_Mail <br>"; echo "Note: $Note <br>";
// Now we format the record (string) for output. $Output = '"' . $Category . '","' . $Last_Name . '","' . $First_Name . '",' . $Company . '","' . $Home_Number . '","' . $Office_Number . '","' . $Fax_Number . '","' . $Mobile_Number . '","' . $Pager_Number . '","' . $Address . '","' . $E_Mail . '","' . $Note . '"' ;
echo $Header_Rec; echo "Output = $Output <br>"; fputs($fileout, "$Output\n"); $Record_Count = $Record_Count + 1;
echo "$line <br><hr>";
} fclose($fileout); echo "Record Count = $Record_Count<br>"; /* The Sharp Pocket Organizer, Model OZ-590 is less that $60. Today, I used this script to load 1,300 addresses into the Sharp, and its memory management function indicated that more that 90% of its memory was free and available. This means I should be able to load 13,000 addresses. The Sharp runs on one AAA battery. It is very slim and fits easily in a shirt pocket. */
echo "<hr />\n". "HAPedit 3.0.11.102 (June 2004 9:46:24 AM)"; ?> </body> </html>
|