Author Topic: little export problem  (Read 5815 times)

acdctabs

  • Newbie
  • *
  • Posts: 9
    • View Profile
little export problem
« 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 :)

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 6216
    • View Profile
Re: little export problem
« Reply #1 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

acdctabs

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: little export problem
« Reply #2 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 ?

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 6216
    • View Profile
Re: little export problem
« Reply #3 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.

acdctabs

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: little export problem
« Reply #4 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 :)
« Last Edit: November 30, 2011, 06:14:27 PM by acdctabs »

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 6216
    • View Profile
Re: little export problem
« Reply #5 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?

acdctabs

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: little export problem
« Reply #6 on: December 03, 2011, 07:24:03 AM »
My own php code :)

And I only use "nicknames" "notes" & "rank".

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 6216
    • View Profile
Re: little export problem
« Reply #7 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?

acdctabs

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: little export problem
« Reply #8 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)
« Last Edit: December 04, 2011, 04:18:36 PM by acdctabs »

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 6216
    • View Profile
Re: little export problem
« Reply #9 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];}

acdctabs

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: little export problem
« Reply #10 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 ^^