Nandini Posted April 25, 2009 Share Posted April 25, 2009 Hi all I want to export a xls or csv file (which is having number of user details) into mysql database table. And i want to validate that xls file. That means i don't want to accept duplicate entries etc. How can i do this. Can anyone send me scripts or url's. Thanq Quote Link to comment https://forums.phpfreaks.com/topic/155590-export-xls-or-csv-file-into-mysql-database/ Share on other sites More sharing options...
Mchl Posted April 25, 2009 Share Posted April 25, 2009 http://dev.mysql.com/doc/refman/5.1/en/load-data.html Quote Link to comment https://forums.phpfreaks.com/topic/155590-export-xls-or-csv-file-into-mysql-database/#findComment-818921 Share on other sites More sharing options...
Nandini Posted April 25, 2009 Author Share Posted April 25, 2009 I am trying to get data from xls file. But i am getting some garbage value. See this output. nࡱ��nnࡱ�nࡱࡱࡱࡱࡱ�nࡱ�nࡱࡱ�nࡱࡱࡱ�nࡱ�nࡱ�nࡱࡱࡱ�nࡱ� The above output i am getting when i execute the following program. <? // open the text file $fd = fopen ("test.csv", "r"); // initialize a loop to go through each line of the file while (!feof ($fd)) { $buffer = fgetcsv($fd, 4096); // declare an array to hold all of the contents of each //row, indexed echo "n"; // this for loop to traverse thru the data cols // when this is re-created with MySQL use the mysql_num_fileds() function to get // this number for ($i = 0; $i < 5; ++$i){ if ($buffer[$i] == ""){ $buffer[$i] = " "; } // print 's with each index echo "$buffer[$i]n"; } echo "n"; } fclose ($fd); ?> Please help me out Quote Link to comment https://forums.phpfreaks.com/topic/155590-export-xls-or-csv-file-into-mysql-database/#findComment-818974 Share on other sites More sharing options...
Mchl Posted April 25, 2009 Share Posted April 25, 2009 Does the file you're parsing look like csv when you open it in notepad? Quote Link to comment https://forums.phpfreaks.com/topic/155590-export-xls-or-csv-file-into-mysql-database/#findComment-819035 Share on other sites More sharing options...
Nandini Posted April 25, 2009 Author Share Posted April 25, 2009 I am very sorry i am not able to understand. Can u send me the script. Quote Link to comment https://forums.phpfreaks.com/topic/155590-export-xls-or-csv-file-into-mysql-database/#findComment-819057 Share on other sites More sharing options...
Mchl Posted April 25, 2009 Share Posted April 25, 2009 I am asking, if you are sure, that file is indeed a csv and not xls file. Quote Link to comment https://forums.phpfreaks.com/topic/155590-export-xls-or-csv-file-into-mysql-database/#findComment-819158 Share on other sites More sharing options...
Nandini Posted April 27, 2009 Author Share Posted April 27, 2009 I am sure. That is csv file. Quote Link to comment https://forums.phpfreaks.com/topic/155590-export-xls-or-csv-file-into-mysql-database/#findComment-820122 Share on other sites More sharing options...
fenway Posted April 28, 2009 Share Posted April 28, 2009 This is a php issue.... Quote Link to comment https://forums.phpfreaks.com/topic/155590-export-xls-or-csv-file-into-mysql-database/#findComment-821223 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.