hello,
i have 10,000 emails in a MS Outlook folder. this is an email of the email (All 10K emails are in the same format).
==========
General Info
Chat Start Time: 20/07/2009 13:24:48
Chat End Time: 20/07/2009 13:28:02
Chat URL: http://www.domainname.com
Referer URL: http://www.anotherdomainname.com
Name: Visitor
Email:
Phone:
Initial Question:
Chat Transcript
[Sam]
Welcome to our website...
[Visitor] Hello
[Sam] How can I help you today?
[Visitor] I am looking for some help [Sam]
Have you looked at this page, domainname.com/page Search Here!
[Visitor] ok thnaks
[Sam] You're welcome!
==========
so you can see, these emails are from a chat program and basically anything can be in the body or the chat area and fields may or may not have values.... but these emails are only in my folder.
I would need to export them?
need to tell magicparser to look for the various data.. somehow?
and i will need to put the data into a mysql DB
PS. once in a DB table, i will need to scrub the data, as there is ALL types of info in the chat area that I must remove... names/phones/address, etc. etc.
I mention that as that is a task I don't know how to do either --- would appreciate any info/tips on that as well.
anyway, can magic parser do this? how to get started?
i would field i would need to a custom setup to tell magic parser what to look for?
THANKs for you help!
FYI. great tool, i found your stuff several months ago... i wish i found it years ago!
has there or where do i find out info on the latest code? upgrades?
Hi there,
As it isn't a linear (line by line) CSV or XML document this isn't actually something that Magic Parser would be able to help with; but I think the format can be handled easily with a couple of PHP's string handling functions. explode() will let you break down each line into the parts either side of the ":" (i.e. field name and value), and then when you reach "Initial Question" you can read the remainder of the file into a single string as the message body.
Assuming one of your message files in the variable $filename (ultimately you can use opendir() and readdir() to automatically process all files in a directory, but it's always best to test and develop this sort of thing on a single file first!) consider the following;
<?php
$filename = "messages/message1.txt";
$fields = array();
$fp = fopen($filename,"r");
while(!$feof($fp))
{
$line = fgets($fp,1024);
$parts = explode(":",$line);
// here the field name is in $parts[0] and value in $parts[1]
// so you can start constructing your SQL directly perhaps,
// or populate a "fields" array as follows
$fields[$parts[0]] = $parts[1];
// and if we have reached Initial Question field, read the rest
// of the file into the value
if ($parts[0]=="Initial Question")
{
while(!$feof($fp))
{
$fields[$parts[0]] .= fgets($fp,1024);
}
}
}
fclose($fp);
// here you can populate your database by using the values from $fields
// use print_r() to study the contents
print_r($fields);
?>
Cheers,
David.