mabart / parsecsv-for-php

Automatically exported from code.google.com/p/parsecsv-for-php
MIT License
0 stars 0 forks source link

Is there any way to parse just a string? #17

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Works good parsing a whole file. But is there any way to parse just a string (a 
single line/record of csv text)?  Thank you.

Original issue reported on code.google.com by techsupp...@gmail.com on 21 Nov 2010 at 9:16

GoogleCodeExporter commented 8 years ago
Yes there is, it's not completely obvious though.

Off the top of my head, the following should work:

$csv = parseCSV();
$csv->heading = false;
$csv->parse('my csv,string,"goes, uhm, here",end');

Original comment by zynode on 21 Nov 2010 at 3:59

GoogleCodeExporter commented 8 years ago
Nope, that just returns an empty array.  And trying it with $csv->auto returns 
an array with the string in one array element.

Is there another way to try? I'd love to get it to work, as this is one of the 
cleanest csv processors I've tried. Thank you.

Original comment by techsupp...@gmail.com on 22 Nov 2010 at 5:35

GoogleCodeExporter commented 8 years ago
FYI, without modifying the library at all, you can get this to work by adding a 
terminator for the line:

$csv->parse('my csv,string,"goes, uhm, here",end' . "\n");

Kinda lame, but that's why it didn't work in the example.  Just put a EOL in 
there.

Original comment by jrie...@gmail.com on 29 Oct 2012 at 2:53