![]() |
CSV upload, once uploaded to a temp folder overwrite the existing database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: CSV upload, once uploaded to a temp folder overwrite the existing database (/showthread.php?tid=57525) |
CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]the_unforgiven[/eluser] Database structure is as follows: Code: CREATE TABLE IF NOT EXISTS `wc_program_temp` ( CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]TheFuzzy0ne[/eluser] Dod gammit! Upon pasting the code into Netbeans, it became apparent where the problem was. I had: Code: $insert_str = rtrim($insert_data, ','); // $insert_data?? What the...? and it should've been: Code: $insert_str = rtrim($insert_str, ','); Again, I've edited my code. Please try it again. If that doesn't work, I'll continue setting up my test environment. CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]the_unforgiven[/eluser] Yes i saw that and changed to it Code: $insert_str = rtrim($insert_str, ','); CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]TheFuzzy0ne[/eluser] OK, not to worry. I'm setting this up to test it out myself. ![]() CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]the_unforgiven[/eluser] Still doesnt work ![]() CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]TheFuzzy0ne[/eluser] OK, I think I've figured this out. The problem? My stupidity... rtrim() wasn't trimming the trailing comma, because it was followed by a newline. DOH! This should finally work now. Sorry for making you wait for so long. CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]TheFuzzy0ne[/eluser] And if you post back saying it doesn't work, I'm going to have to hurt you. ![]() CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]the_unforgiven[/eluser] Oh shit! I best emigrate then! Cos guess what.... It still don't work ![]() ![]() CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]the_unforgiven[/eluser] This Code: //Get the data from some web resource in csv format CSV upload, once uploaded to a temp folder overwrite the existing database - El Forum - 03-25-2013 [eluser]TheFuzzy0ne[/eluser] Ugh... Try it again please. I was using a truncated version of your CSV file, and it turns out there we some double quotes towards the bottom of the file. I now have a database table containing 1,758 rows. |