...

View Full Version : CSV, retrieving and editing data



Aronnn
01-20-2012, 11:40 PM
Hey,

I am attempting to let my users edit a CSV file from their control panel. They all should have 2 "slots". I am using the following format:

"Laur3ns1","world","Laur3ns","190.06752899480915","69.0","1643.384470515287","-32.700108","184.04663"
"Laur3ns2","world","Laur3ns","-1607.703077719658","63.0","1523.51365067294","29.54973","-40.56433"
"Aronnn1","world_nether","Aronnn","-203.0878960285693","64.0","0.49427347759672624","39.3","-175.35004"

What it should do is it should be able to check how many slots you have used, in this case the person Laur3ns used 2 of them and Aronnn only 1. I can develop a panel which allows you to update them both but do not know how to check if they are used and if not add one, and if it is used, update it. The current code I am using to output it is:

<?PHP
$file_handle = fopen("warps.csv", "r");
while (!feof($file_handle) ) {
$line = fgetcsv($file_handle, 1024);
print $line[0] . $line[1] . $line[2] . $line[3] . $line[4] . $line[5] . $line[6] . $line[7] . "<BR>";
}
fclose($file_handle);
?>

If anybody could help me I could highly appreciate it,
Aron

JV-
01-20-2012, 11:56 PM
I suggest using a database for things like this. You can easily manipulate data like this in a database and create easy to use interfaces for it. You can also export data to CSV if you need to.

Aronnn
01-21-2012, 11:37 AM
Thank you for your reply,
I am currently using a plugin that outputs in a CSV file and can only be changed through CSV. I already thought of porting it to MYSQL but since the source has not been released I need to do it with CSV (the plugin is writen in java).

BluePanther
01-21-2012, 09:36 PM
http://php.net/manual/en/function.fgetcsv.php

That could be something that applies. Have a good look through it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum