On 9/5/07, Peter P. wrote: > Vitaliy maksimov.org> writes > > What other "text-friendly" languages are out there, besides PHP and Pyt= hon? > > Which one do you prefer to use for simple parsing? > > For simple formats such as CSV even a shell is powerful enough. The quest= ion is, > what do you need to do with the data after you parse it. If it is anythin= g other > than fixed-record-count per line, audited data then please consider using= a more > evolved language than awk or shell or even php. > CSV is not so simple. Quoting from http://www.faqs.org/docs/artu/ch05s02.ht= ml: " In fact, the Microsoft version of CSV is a textbook example of how not to design a textual file format. Its problems begin with the case in which the separator character (in this case, a comma) is found inside a field. The Unix way would be to simply escape the separator with a backslash, and have a double escape represent a literal backslash. This design gives us a single special case (the escape character) to check for when parsing the file, and only a single action when the escape is found (treat the following character as a literal). The latter conveniently not only handles the separator character, but gives us a way to handle the escape character and newlines for free. CSV, on the other hand, encloses the entire field in double quotes if it contains the separator. If the field contains double quotes, it must also be enclosed in double quotes, and the individual double quotes in the field must themselves be repeated twice to indicate that they don't end the field. " The bad results of proliferating special cases are twofold. First, the complexity of the parser (and its vulnerability to bugs) is increased. Second, because the format rules are complex and underspecified, different implementations diverge in their handling of edge cases. Sometimes continuation lines are supported, by starting the last field of the line with an unterminated double quote =97 but only in some products! Microsoft has incompatible versions of CSV files between its own applications, and in some cases between different versions of the same application (Excel being the obvious example here)." -- = Mark Rages, Engineer Midwest Telecine LLC markrages@midwesttelecine.com -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist