mabart / parsecsv-for-php

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

Incorrect CSV files get parsed without error #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. just try to parse a file containing plain wrong data such as a field
"some data" get replaced by "some" data" which cannot by valid

What is the expected output? What do you see instead?
I expected an error, instead line get dropped silently (parsing seems to
stop but valid rows are returned, there's no error message).

What version of the product are you using? On what operating system?
0.3.1

Please provide any additional information below.
Parsing valid file is really easy, the problem always comes when parsing
broken files. In such case at least would be good to know that there's a
problem you can enforce valid file to be sent from user.

Original issue reported on code.google.com by yizhi....@kneip.com on 26 Mar 2008 at 2:30

GoogleCodeExporter commented 8 years ago
This issue was brought to my attention some while ago. I've finally found some 
time today to have a look at 
it.

As for single double quotes inside quoted values, I'll have parseCSV use some 
common sense and figure 
out its not a terminating quote if the next non-whitespace character is not the 
delimiter char or a new line.

I will of course also look into what I can do about the lack of validation and 
error reporting for files that have 
incorrect formatting.

Thanks for bringing this to my attention, and reminding me I need to fix it. 
I'm forgetful when I've got a lot of 
work... heh *whistles innocently*

Original comment by zynode on 27 Mar 2008 at 12:32

GoogleCodeExporter commented 8 years ago
This is being moved to the top of my todo list now, since other things have 
been bumping it down. And now, for 
some much needed sleep...zZzzZz....

Original comment by zynode on 31 Mar 2008 at 11:07

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I've rewritten the handling enclosure characters so it reports when unexpected 
things happen. Unfortunately, 
due to the design of CSV itself, its extremely hard to figure out and correct 
what's wrong unless you're human.

Because of this, it will report an error code of "1" even when it believes its 
managed to fix the error. An error 
code of "2" means critical errors which typically break parking was found. In 
both cases it still continues 
parsing the input data in hopes of the syntax errors not breaking anything. The 
error code is accessible via 
$obj->error, additionally, $obj->error_info contains an array with more details 
for each error found.

This code is currently available in the SVN trunk if you wanna have a look. I 
should be realeasing it as 0.3.3 
beta soon after some more testing as its the most significant change I've ever 
done to the core parsing code 
since I originally wrote it. 

Also, if you have any real world examples of corrupt or invalid CSV files 
please attach them to this issue so I 
have more examples to work with than the ones I corrupted myself... lol

P.S. I gotta pay slightly more attention to what I'm writing when I'm using my 
iPhone, cause jesus this 
comment had some stupid-ass typos and shit :P

Original comment by zynode on 7 Apr 2008 at 6:30

GoogleCodeExporter commented 8 years ago
I don't see the reporting functionality you refer to above.  In fact I don't see
where the error  and error_info objects are implemented at all:

brandon@halpert:~/Desktop/parsecsv-0.3.2$ ls
ChangeLog.txt  examples  License.txt  parsecsv.lib.php
brandon@halpert:~/Desktop/parsecsv-0.3.2$ grep -iR error *
ChangeLog.txt:- Fixed a small code error which would cause PHP to

More detailed error reporting will be very helpful in cases where I'm trying to 
parse
large CSV files and it's rather unclear where the parser errors out.  Thanks 
for a
great tool, by the way.

-Brandon

Original comment by brandon....@gmail.com on 9 Apr 2008 at 5:10

GoogleCodeExporter commented 8 years ago
I'm sorry i wasn't fully clear about where the error reporting has been 
implimented. Currently it's only on in 
the trunk on the SVN repository. Error reporting will be part of v0.3.3 (I 
might call it 0.4 if any more semi-big 
changes occur). Currently you can find the error reporting code for testing 
here:
http://parsecsv-for-php.googlecode.com/svn/trunk/parsecsv.lib.php

I'll hopefully have some more time on my hands tonight to run it through some 
more tests. Error reporting 
required some of the biggest changes to the core parsing logic of parseCSV 
since I first wrote the code back 
in november 2006. Hence the new code had some bugs from the beginning, which I 
wanna be sure are all 
gone before I release it :)

Original comment by zynode on 9 Apr 2008 at 7:11

GoogleCodeExporter commented 8 years ago
I guess I didn't read comment 4 closely enough:
> This code is currently available in the SVN trunk if you wanna have a look.

:-)  Thanks again for your help and for the very useful parser.  It works like 
a charm.

Original comment by brandon....@gmail.com on 10 Apr 2008 at 12:48

GoogleCodeExporter commented 8 years ago
I've just released the latest changes as v0.4-beta, it has a small bug-fix 
compared to the copy in the SVN trunk 
the other day that i linked you to.

Aside from situations like this, I generally recommend you stick with the 
latest releases, as sometimes I might 
update the trunk with half-complete code *whistles innocently* :)

Original comment by zynode on 11 Apr 2008 at 6:30