The Tournament Director Forums

Main => Beta Testing => Topic started by: acdctabs on November 30, 2011, 05:41:56 AM

Title: little export problem
Post by: acdctabs on November 30, 2011, 05:41:56 AM
Hi,
when you "extract" rank / names at the end of the tournament without column name, it make some "" "" around first line of csv anyway.
If you could correct it, it will be great :)
Title: Re: little export problem
Post by: Corey Cooper on November 30, 2011, 10:11:59 AM
This is intentional, and not a bug.  Quotations around column values are acceptable in CSV files, and necessary at times.  They allow, for example, a column value to have a comma in it (without the comma signaling the start of the next column).  When the TD exports to CSV, all values in the first line are quoted to avoid a "feature" of Microsoft Excel where Excel thinks the file is a SYLK file: http://support.microsoft.com/kb/323626
Title: Re: little export problem
Post by: acdctabs on November 30, 2011, 11:59:40 AM
It was not the case before.
Could you put a case I can check to desactivate it ?
Title: Re: little export problem
Post by: Corey Cooper on November 30, 2011, 03:11:26 PM
Correct, it was not the case before.  It was added to deal with the issue I mentioned in my previous post.  But I must ask, why is this an issue for you?  The CSV file that is exported is standard CSV.  Quotations around column values are completely legal and even necessary in many cases.
Title: Re: little export problem
Post by: acdctabs on November 30, 2011, 06:06:28 PM
Long story ... I'll try to make it short.

I use csv to  export players after tournaments, csv format, to send it to a database.
The quotations are embarrassing because I need to edit the file to remove them before sending it to the database.

So if i could desactivate the quotes i'll be happy :)
Title: Re: little export problem
Post by: Corey Cooper on December 02, 2011, 10:40:02 AM
Sounds like whatever is importing from CSV doesn't know how to import from CSV.  As I said, quotations are perfectly valid.  In fact they are at times necessary.  For example, let's say you used the Name Format:

{LN}, {FN}

(which would be last name comma first name) and exported the "Name" column, you'll get things like:

"Cooper, Corey"

If you omit the quotes, anything attempting to read the CSV file would think that is two columns instead of just one column which it really is.  What are you using to import into your database?
Title: Re: little export problem
Post by: acdctabs on December 03, 2011, 07:24:03 AM
My own php code :)

And I only use "nicknames" "notes" & "rank".
Title: Re: little export problem
Post by: Corey Cooper on December 03, 2011, 09:36:48 AM
PHP has built-in functions for reading CSV files, like str_getcsv() and fgetcsv().  Are those not properly parsing the CSV file or are you using your own code to parse the file?
Title: Re: little export problem
Post by: acdctabs on December 04, 2011, 04:16:29 PM
That's the part of the code I'm using :

Code: [Select]
$fic = fopen($dossier . $fichier, "r");
$i = 0;
while (!feof($fic)) {
$ligne = fgets($fic);
$liste = explode(",",$ligne);
$i++;
if ($i < $NbLigne) {$pseud = substr($liste[1], 0, -2);} else {$pseud = $liste[1];}

where $dossier & $ficher are the path/name of file

so we can say it's my own code but i did'nt invent it, I copy it from a friend who did the same thing before (and can't tell you where he finds it or if he invents it)
Title: Re: little export problem
Post by: Corey Cooper on December 05, 2011, 12:55:03 PM
$fic = fopen($dossier . $fichier, "r");
$i = 0;
while (!feof($fic)) {
$liste = fgetcsv($fic);
// $liste = explode(",",$ligne);
$i++;
if ($i < $NbLigne) {$pseud = substr($liste[1], 0, -2);} else {$pseud = $liste[1];}
Title: Re: little export problem
Post by: acdctabs on December 11, 2011, 05:13:19 AM
fix the "" problem but create another one because of ANSI / UTF8.

Thanks anyway, i'll continue to remove "" manually ^^