Hi All,
I want the code below to append two more (Customer Number and Customer File) fields in the column row of the csv file first.
Then append ( C048468145-2) values for the Customer Number field and (C048468145-2.csv ) value for the Customer File field second.
Currently, the script Cut exisitng fields in the first row to make room for the new append before it Paste the new field. Not what I really want to achieve.
<?
// Filename
$filename = "c:\C048468145-2.csv";
// Prepare extra column header for the csv file
$cust_file = "Customer File,";
// Prepare another column header for the csv file
$cust_num = "Customer Number,";
// Open file for writing and reading
$fd = fopen ($filename, "a+")or die("Could not open file for append!");;
// Write the value of the variable $cust_file at the beginning of the first row.
fwrite ($fd, $cust_file ) or die("Could not write $cust_file to file");
// Write the value of the variable $cust_num at the beginning of the first row.
fwrite ($fd, $cust_num) or die("Could not write $cust_num to file");
//Then append ( C048468145-2) and ( C048468145-2) simultanously for each data row below the columns.
// Append the contents of the file to the variable $content
$contents = fread ($fd,filesize ($filename)) or die ("Could not read file after append or write!");
//Close file after reading
fclose ($fd);
?>
ORIGINAL DATA CONTENT BEFORE APPEND
Item,Product Number,Product,Type,Date,Time,Stock Number,Cost GST$
,822454396,Local,23-Aug,8:12 AM,822416654,7.25,,
822454396,Local,23-Aug,1:43 PM,822415333,5.36,,
DATA CONTENT AFTER APPEND
Customer Name,Customer File,Item,Product Number,Product,Type,Date,Time,Stock Number,Cost GST$
C048468145-2,C048468145-2.csv,822454396,Local,23-Aug,8:12 AM,822416654,7.25,,
C048468145-2,C048468145-2.csv,822454396,Local,23-Aug,1:43 PM,822415333,5.36,,
Thanks for your help in advance.
Justman