[consulting] Editing a .txt file with script

Holly Ferree hferree at gmail.com
Fri Oct 22 19:52:15 UTC 2010


Hello All,

I have figured out how to open a text file and erase and add new content...
I also know how to add content at the end of the file....

How do I do search and replace?

This is the default look for the line of code:

      1167-67271: 10/18  6:45p 186MB 111Pts v8.55.4/9.0.2.3642 Tipsword,
Georgia         SUCCESS

This is how I was told to format it (a little more complex than before):

1167, 67271, 10/18/2010(CONVERT TO DATE FORMAT), 6:45p(CONVERT TO TIME
FORMAT 18:45), 186000000, 111, v8.55.4, 9.0.2, 3642, Tipsword, Georgia,
SUCCESS

This is the code that I have so far:

<?php
$myFile = "test.txt";
$fh = fopen($myFile, 'r+') or die("can't open file");

WHAT CAN I PUT HERE TO REPLACE ALL THE SPACES AND THEN ADD A COMMA WEAR
NEEDED?

fclose($fh);


--------------------
It needs to be a script because it has hundreds of lines and the report
comes in once a day. Any ideas?

Any help is appreciated,

Holly Ferree

(one person I asked suggested using visual basic instead of php by creating
a .vbs or .vba script using Regular Expressions (Regex) (mix of find and
replace strings like \s+ .... any help on what experssions to use would be
great) and then using an action in outlook 2007 to run the script when the
subject name of Connect Report with the connect.txt attached is recieved)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/consulting/attachments/20101022/73949e82/attachment.html 


More information about the consulting mailing list