Skip to content

Instantly share code, notes, and snippets.

@myuon
Created September 17, 2019 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myuon/f3100b2e53fe0129380d1626c14d13c3 to your computer and use it in GitHub Desktop.
Save myuon/f3100b2e53fe0129380d1626c14d13c3 to your computer and use it in GitHub Desktop.
csv-sanitize
# https://www.quora.com/What-is-a-sed-script-that-will-remove-the-n-character-but-only-if-it-is-inside-characters-delimited-string-not-the-n-that-is-actually-at-the-end-of-the-virtual-line
$ mlr --csv --rs lf --implicit-csv-header --headerless-csv-output --quote-all put '
for (col_no in $*) {
$[col_no]=gsub($[col_no], "\n", " \\\\n ")
}
' my.csv > sanitized.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment