Hello all, nice to know this helpfull forum,
I'm a totally newbie and I need advice,
I want to import a CSV to a table in sql, but the problem is the CSV has very strange format.
==================================
Telephone,=,'88213839
Name,=,John Doe
Currency,=,USD
Date,Information,Source,Total,,Balance
'30/04,ATM 28/04 ,'0000,000000000500000.00,DB,1.171892966E7
'30/04,DEBIT 28/04 LAWSON,'0000,000000000092100.00,DB,1.162682966E7
'30/04,DEBIT 29/04 7-ELEVEN,'0000,000000000068000.00,DB,1.155882966E7
'30/04,DEBIT 30/04 CARREFOUR,'0000,000000000254150.00,DB,1.130467966E7
Begin,=,12218929.66
Income,=,3.6101013456E8
Outcome,=,1.080887041E7
Balance,=,3.6242019381E8
======================================
All i need is to import the middle section
"
'30/04,KARTU DEBIT 30/04 CARREFOURCENTRAL,'0000,000000000254150.00,DB,1.130467966E7
"
and append all the value to the SQL table. and i don't want to add same field again to the database.
I have use this code
$row = 1;
if (($handle = fopen("4.txt", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
//echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
if ($row > 6){
echo $data[$c] . "<br />\n";}
}
}
fclose($handle);
=============================
But what i don't know how to do is do delete the last 4 lines
Begin,=,12218929.66
Income,=,3.6101013456E8
Outcome,=,1.080887041E7
Balance,=,3.6242019381E8
============
and how to append then to a sql table?
sorry for super totally novice questions. try to solve it but still meet the death end.
:)