Question : need a script to convert csv to txt

I need a simple script (php) or small app or macro, that will convert a csv file into txt files.. 1 text file per row.

The script/app will need to do the following..

1. Able to select the delimiter I mainly use comma,pipe,tab,semicolon

2. able to enter a template for the output.. Example

%11%

%11%


%11% - $%14%


%7%



Where the numbers are based on the column numbers..

The output file names will be completely random.. such fhshTrtd55.txt

Any help is appreciated.
Thanks,
akiles

Answer : need a script to convert csv to txt

Ok, I've installed php on this machine and adjusted the code, it's attached.
But if you want a good result you have to remove the " from the csv file.
When saving it with excell there should be an option to quote string with ", remove that.

I attach also a example txt file that the script had produced on my machine
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
\"%11%\"

%11% - $%14%

%7%

"; $csv = fopen("sample.csv.xls", 'r'); $k = 1; while ($cvs !== false && !feof($csv)) { $string = fgets($csv); $data_array = explode($csv_delimiter, $string); $return_string = $template; for ($i = 1; $i <= sizeof($data_array); $i++) { $return_string = str_replace("%".$i."%", $data_array[$i], $return_string); } touch("file".$k.".txt"); file_put_contents("file".$k.".txt", $return_string); $k++; } ?>
 
test txt file
 
Random Solutions  
 
programming4us programming4us