in reply to Re^3: CSV data processing
in thread CSV data processing
Text::CSV has grown a lot of configuration settings (from the docs):
verbatimThis is a quite controversial attribute to set, but it makes hard things possible.
The basic thought behind this is to tell the parser that the normally special characters newline (NL) and Carriage Return (CR) will not be special when this flag is set, and be dealt with as being ordinary binary characters. This will ease working with data with embedded newlines.
When verbatim is used with getline (), getline auto-chomp's every line.
Imagine a file format like
M^^Hans^Janssen^Klas 2\n2A^Ja^11-06-2007#\r\nwhere, the line ending is a very specific "#\r\n", and the sep_char is a ^ (caret). None of the fields is quoted, but embedded binary data is likely to be present. With the specific line ending, that shouldn't be too hard to detect.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|