in reply to Re^3: CSV file
in thread CSV file

Your regex still doesn't do what the OP is asking for, namely to split the line into the comma-delimited fields, taking care not to split on the comma if it is within quotes. Nor will it handle tohe given data correctly (tip: there's a telephone number which is not part of the address). Do try to read what other people have written more carefully, especially if it has been explicitly pointed out to you.

As for your other remark, this is an area where it's unwise to use regular expressions because it's rather complicated to come up with a robust solution (take a look at Mastering Regular Expressions, it handles this subject in some detail) and there are perfectly well-developed solutions for parsing CSV files in CPAN, which have already been pointed out by others.


Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan

Replies are listed 'Best First'.
Re^5: CSV file
by Moron (Curate) on Oct 31, 2005 at 17:00 UTC
    Well, the OP didn't in fact ask for that, although I can agree now that they probably should have done.

    -M

    Free your mind