Your CSV file seems to be a TSV file actually. It doesn't use commas, but tabulators for separating the fields.
Up vote 0 down vote favorite share g+ share fb share tw.
I am using the following script to import data into my mysql database from CSV files. The CSV is setup like this : Name Postcode fred hd435hg bob dh345fj Above is what it looks like in excel, in raw csv format viewed in notepad it looks like this : name,postcode frank,ng435tj The problem I am having is for some reason the postcode column isnt getting imported at all, also the header row is getting imported as a record too, is it possible to make it skip the first row?. I have been through the code and cant see why the postcode is not being pulled in, it is very odd.
Php mysql csv fopen link|improve this question edited Jan 15 at 0:20 asked Jan 15 at 0:10user1148760215 75% accept rate.
Your CSV file seems to be a TSV file actually. It doesn't use commas, but tabulators for separating the fields. Therefore you need to change the fgetcsv call.
Instead of ',' use the tab: while (($data = fgetcsv($handle, 1000, "\t") ... And to also skip the header row, add another faux fgetcsv before the while block: fgetcsv($handle); while (...) { That will skip the first line. (A simple fgets would also do. ) Oh, just noticed: The postcode might also get dropped because you concat it into the string as decimal with the sprintf placeholder %d for $postcode.
Should that field actually contain lettery, like in your example, then that wouldn't work. -- Though I presume that's just a wrong example printout.
Sorry thats because I was opening it in excel, if I open it in notepad it looks like this – user1148760 Jan 15 at 0:19 name,postcode frank,ng435tj – user1148760 Jan 15 at 0:19 Uh oh, Okay. Then please ignore all my theories up to this point. – mario Jan 15 at 0:20 But does the postcode actually contain letters?
Or is it numeric as one would assume for postcodes? – mario Jan 15 at 0:21 by the way uk postcodes have numbers and letters, so what would the correct sprintf placeholder be? – user1148760 Jan 15 at 0:22.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.