4 ms·
> Well, no, you can do exactly that in a single line with tail, head, split and cat. You can't, because csv records may span multiple lines. So dicing them wit
by burntsushi 7y ago
> Well, no, you can do exactly that in a single line with tail, head, split and cat.
You can't, because csv records may span multiple lines. So dicing them with standard tools may subtly break them. Unless you know your particular CSV data only has single line records.
(I take your broader point though. It's just that CSV is a bad example, because you usually wind up needing specialized tools to deal with them. It's likely that your PHP script would actually be more correct!)
- mynegation 7y agoThank you for xsv and other things, Andrew. To GP: also - CSV headers. Still possible in one line of shell, but it is starting to get unwieldy.
- CaptArmchair 7y agoThanks for clarifying that overlooked detail. I should have mentioned another lesson for junior developers: learn to understand the structure of your data and avoid making assumptions about formatting.