Sorry, I may have missed something, but I'm trying to export data as csv and it results is a table with only one column.

Someone with the same issue?

CommentFileSizeAuthor
#3 1866798-3-csv-enclosure.patch390 byteskevin hankens

Comments

kevin hankens’s picture

Hey, thanks for the report, if you can give me some more info I can help debug it. Is there any way you can describe your table field settings and give me some example data? Also, feel free to direct message me a link where I can see it in action.

Thx!

benevides’s picture

Hello Kevin, thanks for your reply. I am sending the link to my table so that you can download.

http://www.proppi.uff.br/sistema-financeiro/node/5

kevin hankens’s picture

StatusFileSize
new390 bytes

We should probably explicitly set it to enclose values in quotes. Can you try the attached patch?

kevin hankens’s picture

Actually, on closer inspection, the CSV file that I got from your server looks ok. The first three rows look like:

Cod,Descritivo,Unidade,Quantidade
"BR0279249 ","CANETA CORRETIVA, PLÁSTICO, PLÁSTICO, 8 ML, ESCRITA                                                          ","UND ",12
"BR0279250 ","CANETA CORRETIVA, PLÁSTICO, PLÁSTICO 4 ML, ESCRITA  ","UND ",
...

Also, what are you using to view the CSV? Are you seeing something different when you open the file in a text editor?

benevides’s picture

still not working.

// Save the data as a CSV file.
foreach ($table as $row) {
fputcsv($fp, $row, ',', '"');
}

fclose($fp);

Results in a single column table.

benevides’s picture

I'm using excel to open the resultant tables. In a text editor this table looks like this:

Cod,Descritivo,Unidade,Quantidade
"BR0279249 ","CANETA CORRETIVA, PLÁSTICO, PLÁSTICO, 8 ML, ESCRITA ","UND ",12
"BR0279250 ","CANETA CORRETIVA, PLÁSTICO, PLÁSTICO 4 ML, ESCRITA ","UND ",
"BR0279251 ","CANETA CORRETIVA, PLÁSTICO, PLÁSTICO 7 ML, ESCRITA ","UND ",
"BR0279252 ","CANETA CORRETIVA, PLÁSTICO, PLÁSTICO 8 ML, DESENHO ","UND ",
"BR0364462 ","CANETA CORRETIVA, PLÁSTICO, ESCRITA, CARGA FITA ","UND ",
"BR0279261 ","CANETA CORRETIVA, PLÁSTICO, METAL, 9 ML, ESCRITA ","UND ",
" BR0297150 ","CANETA CORRETIVA, PLÁSTICO, PLÁSTICO, 5 ML, ESCRITA ","UND ",
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,FINA AZUL ","CX 12 ",24
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,FINA PRETO ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,FINA VERMELHO ","CX 12 ",24
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,FINA VERDE ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,FINA AZUL ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,FINA PRETO ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,FINA VERMELHO ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,FINA VERDE ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,MEDIA AZUL ","CX 12 ",24
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,MEDIA PRETO ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,MEDIA VERMELHO ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,MEDIA VERDE ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,MEDIA AZUL ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,MEDIA PRETO ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,MEDIA VERMELHO ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,MEDIA VERDE ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,GROSSA PRETO ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,GROSSA VERMELHO ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,GROSSA VERDE ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, PLASTICO,GROSSA AZUL ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,GROSSA AZUL ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,GROSSA PRETO ","CX12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,GROSSA VERMELHO ","CX 12 ",
"BR00099 ","CANETA ESFEROGRÁFICA, EMBORRACHADA,GROSSA VERDE ","CX 12 ",
"BR0279311 ","CANETA MARCA-TEXTO, PLÁSTICO, FLUORESCENTE, AZUL ","CX 12 ",24
"BR0279312 ","CANETA MARCA-TEXTO, PLÁSTICO, FLUORESCENTE, VERDE ","CX 12 ",24
"BR0279313 ","CANETA MARCA-TEXTO, PLÁSTICO, FLUORESCENTE, AMARELA ","CX 12 ",
"BR0279314 ","CANETA MARCA-TEXTO, PLÁSTICO, FLUORESCENTE, LARANJA ","CX 12 ",
"BR0279315 ","CANETA MARCA-TEXTO, PLÁSTICO, FLUORESCENTE, VERMELHA ","CX 12 ",
"BR0279316 ","CANETA MARCA-TEXTO, PLÁSTICO, FLUORESCENTE, ROSA ","CX 12 ",
"BR0202036 ","HIDROCOR PINCEL ATÔMICO, PLÁSTICO, FELTRO, RECARREGÁVEL, AZUL ","CX 12 ",
"BR0202037 ","HIDROCOR PINCEL ATÔMICO, PLÁSTICO, FELTRO, RECARREGÁVEL, PRETA ","CX 12 ",
"BR0202039 ","HIDROCOR PINCEL ATÔMICO, PLÁSTICO, FELTRO, RECARREGÁVEL, VERMELHA "" ","CX 12 ",
"BR0229800 ","HIDROCOR PINCEL ATÔMICO, PLÁSTICO, NÁILON, RECARREGÁVEL, VERDE ","CX 12 ",
"BR0202040 ","HIDROCOR PINCEL ATÔMICO, PLÁSTICO, FELTRO, DESCARTÁVEL, AZUL ","CX 12 ",
"BR0202041 ","HIDROCOR PINCEL ATÔMICO, PLÁSTICO, FELTRO, DESCARTÁVEL, PRETA ","CX 12 ",
" BR0202043 ","HIDROCOR PINCEL ATÔMICO, PLÁSTICO, FELTRO, DESCARTÁVEL, VERMELHA"" ","CX 12 ",
"BR0228841 ","HIDROCOR PINCEL ATÔMICO, PLÁSTICO, FELTRO, DESCARTÁVEL, VERDE ","CX 12 ",
"BR00099 ","CANETA HIDROCOR GRANDE, ESCRITA MEDIA - CORES ","CX 12 ",
"BR00099 ","CANETA HIDROGRÁFICA 12 CORES PONTA GROSSA, SIMILAR A PILOT ","CX 24 ",
"BR00099 ","CANETA PARA QUADRO BRANCO SIMILAR A WBM-7 COR AZUL ","CX 12 ",
"BR00099 ","CANETA PARA QUADRO BRANCO SIMILAR A WBM-7 COR PRETA ","CX 12 ",
"BR00099 ","CANETA PARA QUADRO BRANCO SIMILAR A WBM-7 COR VERDE ","CX 12 ",
"BR00099 ","CANETA PARA QUADRO BRANCO SIMILAR A WBM-7 COR VERMELHA ","CX 12 ",
"BR00099 ","CANETA P/RETROPROJETOR COR AZUL ","CX 12 ",
"BR00099 ","CANETA P/RETROPROJETOR COR PRETA ","CX 12 ",24
"BR00099 ","CANETA P/RETROPROJETOR COR VERDE ","CX 12 ",
"BR00099 ","CANETA P/RETROPROJETOR COR VERMELHA ","CX 12 ",
"BR00099 ","CANETA PERMANENTE PARA CD/DVD COR Preta ","CX 12 ",
"BR00099 ","CANETA PERMANENTE PARA CD/DVD COR Vermelha ","CX 12 ",
"BR00099 ","CANETA PERMANENTE PARA CD/DVD COR Verde ","CX 12 ",
"BR00099 ","CANETA PERMANENTE PARA CD/DVD COR AZUL ","CX C/12 ",

kevin hankens’s picture

Ok, thanks, now we're getting somewhere! Now to start deducing :)

We know that the columns are intact, comma separated and enclosed in quotes. The one inconsistency that I immediately see is that when the last column is empty, there isn't an empty quote "". I wonder if that could be it.

Can you copy and paste the first two lines into a new .csv file using a text editor, then open that in excel?

Cod,Descritivo,Unidade,Quantidade
"BR0279249 ","CANETA CORRETIVA, PLÁSTICO, PLÁSTICO, 8 ML, ESCRITA ","UND ",12

If that doesn't work, can you try enclosing the 12 in quotes?

Let me know if either of those generate the proper columns.

benevides’s picture

None of my tries did work. First two lines still giving me a table with one single column, and wrapping 12 in quotes didn't help either.

I'm wondering if this could have some thing about special characters in the table.

Sorry I'm a noob "front end" user, can't help much and my english is a crap. But I will do what I can to help.

This is a great module! We could have a way to download a .xls file. That would be great!

kevin hankens’s picture

Bummer. I was hoping it would be something easy :)

No worries, I'll do some googling to see if there are any obvious solutions. I'm using libre office here and it seems to interpret the columns correctly. That said, there are way more people using excel, so it will be good to solve this properly.

There are some libraries for saving xls files, but it's a difficult business. Hopefully we can figure this out and just use CSV files as they are so much simpler.

Keep in touch if you figure anything out!

benevides’s picture

Ok, using www.libreoffice.org, and setting the document to UTF-8 the table works like a charm.

jenlampton’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

This is a very old issue, and I cannot reproduce it today. If the problem persists please reopen.