File: cvs

package info (click to toggle)
plan 1.8.4-9
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,964 kB
  • ctags: 1,986
  • sloc: ansic: 24,493; perl: 1,361; makefile: 531; sh: 516; yacc: 119; sed: 17
file content (20 lines) | stat: -rwxr-xr-x 452 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/sed -f
# sed commands to change grok database to comma separated fields.
# usage: "csv file.db"  e.g. "csv countries.db | nl | less" 
#
# Modus Operandi:
#  First combine "\" splitted lines with " | " marker; again and again
#  Then change "," to ";" to avoid extra fields
#  Then change separator ":" to ","
#
# Stoffel Lombard <lombc@clom.me.up.ac.za>
{
:again
/\\$/N
s/\\ *\n/ | /g
/\\$/bagain
s/\\:/|||||/g
s/,/;/g
s/:/,/g
s/|||||/:/g
}