I'm using the following CSV file:
http://git.veekun.com/pokedex.git/blob/HEAD:/pokedex/data/csv/abilities.csv
As you can see, the "effect" column takes multiple rows in certain places. The line spaces need to be preserved, but I can always just replace them with *** then convert back when displayed, like:
1, Stench, 3, "This Pokémon's moves have approximately a 10% chance to make the target [flinch]{mechanic}.***This ability does not stack with a held [King's Rock]{item}.***Overworld: The wild encounter rate is halved while this Pokémon is in the party.", Has a chance of making the opponent [flinch]{mechanic} when attacking.
When I try to import it using phpmyadmin, it just totally doesn't know what's going on and screws up.
Any help?
The data is separated by a comma. There should be 5 fields:
id, name, generation_id, effect, short_effect
id is an int(3)
name is a varchar(20)
generation_id is an int(1)
effect is a text
short_effect is a text
Also, only "effect" text has quotes around it. "name" and "short_effect" are open, although "short_effects" will always occur after the end of "effect" on the same line.
Each new row of data as it should go into the database as will start with an integer.
I know how to parse everything like
$handle = fopen("$filename", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$import="INSERT into info(name,address,food) values('$data[0]','$data[1]','$data[2]')";
mysql_query($import) or die(mysql_error());
}
fclose($handle);
but I haven't touched PHP in several months and can't come up on the idea of how to parse a file like that one.
http://git.veekun.com/pokedex.git/blob/HEAD:/pokedex/data/csv/abilities.csv
As you can see, the "effect" column takes multiple rows in certain places. The line spaces need to be preserved, but I can always just replace them with *** then convert back when displayed, like:
1, Stench, 3, "This Pokémon's moves have approximately a 10% chance to make the target [flinch]{mechanic}.***This ability does not stack with a held [King's Rock]{item}.***Overworld: The wild encounter rate is halved while this Pokémon is in the party.", Has a chance of making the opponent [flinch]{mechanic} when attacking.
When I try to import it using phpmyadmin, it just totally doesn't know what's going on and screws up.
Any help?
The data is separated by a comma. There should be 5 fields:
id, name, generation_id, effect, short_effect
id is an int(3)
name is a varchar(20)
generation_id is an int(1)
effect is a text
short_effect is a text
Also, only "effect" text has quotes around it. "name" and "short_effect" are open, although "short_effects" will always occur after the end of "effect" on the same line.
Each new row of data as it should go into the database as will start with an integer.
I know how to parse everything like
$handle = fopen("$filename", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$import="INSERT into info(name,address,food) values('$data[0]','$data[1]','$data[2]')";
mysql_query($import) or die(mysql_error());
}
fclose($handle);
but I haven't touched PHP in several months and can't come up on the idea of how to parse a file like that one.