Hi, I am reading a csv file and i read it line by line.. but there is a problem.
It reads the csv line but put the spaces between each charachter.. and the line gives problem when i use it write in the mysql table..
Here is the out put of the array...
temp1[0]: ÿ
temp1[1]: þ
temp1[2]: c
temp1[3]:
temp1[4]: h
temp1[5]:
temp1[6]: e
temp1[7]:
temp1[8]: c
temp1[9]:
temp1[10]: k
temp1[11]:
temp1[12]:
temp1[13]:
temp1[14]: i
temp1[15]:
temp1[16]: t
temp1[17]:
temp1[18]:
temp1[19]:
temp1[20]: o
temp1[21]:
temp1[22]: u
temp1[23]:
temp1[24]: t
Here is the code i am using to read the csv.. i can post the csv also if any one needs it...
$readcsv = fopen('csvdata/1747.csv', 'r');
$row = 0;
$r = 0;
$activerow = 0 ;
while ($line = fgetcsv($readcsv,1024)) {
$data[$row] = $line[0];
// echo "Data is ".$data[$row];
$row++;
}
$temp1 = $data[0];
/*The While loop is there to just check the spaces, it is not the part of program*/
while ( $r < 50){
echo "\ntemp1[".$r."]: ".$temp1[$r];
$r++;
}
$sql = "CREATE TABLE $temp1 (dish_id INT,dish_name VARCHAR(255),price DECIMAL(4,2),is_spicy INT)"; echo "\n\n\n\n".$sql;
mysql_query($sql) or die("\nCannot query ".mysql_error());