I have an autogenerated csv file that contains metadata in the top 9 lines...The header starts on line 10. Is there anyway to tell the parser to ignore the first 9 carriage returns and start parsing on the 10th?
Thanks
Thanks David...that works great...
any chance there is a 5th undocumented parameter could be added that tells the parser to ignore x number of lines at the bottom of the file?
Hi,
That's much harder to achive because the parsing is a serial process - the script has no idea how near to the end of the file it is until it gets there.
However, depending upon the content of thost tailing lines it is normally quite easy to detect them within your record handler function and discard accordingly.
This is usually done by testing a value; let's say the first field ($record["FIELD1"] if you don't have a header row) and make sure that it makes sense in the context of the data that you're processing.
Hope this helps!
Cheers,
David.
Hi,
Yes - there is an undocumented feature for supporting this. You have to supply a 4th parameter in the format string for a CSV format file indicating the number of pre-amble lines to skip.
For example, if the file type is CSV, comma separation, header row and values are not quoted then your existing format string would be:
"csv|44|1|0"
If you wanted the same format but to skip the first 9 lines, use:
"csv|44|1|0|9"
Hope this helps,
Cheers,
David.