-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexportcomments.awk
More file actions
executable file
·33 lines (31 loc) · 896 Bytes
/
exportcomments.awk
File metadata and controls
executable file
·33 lines (31 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/local/bin/xmlgawk -f
# reads xml blog export and creates txt file for each comment
XMLCHARDATA {
switch ( XMLPATH ) {
case /comment\/author/:
if ( $0 == "" ) {
ncomment["anonymous"]++
author = "anonymous" ncomment["anonymous"]
}
else
{ author = $0 }
ncomment[author]++
commentid = author "." ncomment[author]
break
case /comment\/text/:
gsub("\n", " ")
gsub(/"/, "\"\"")
commenttext = $0
printf "%s,%s,\"%s\"\n", post, commentid, commenttext
break
case /url/:
post = $0
break
}
}
XMLENDELEM == "comment" {
if (! commentid in alwaysprinted) {
printf "%s,%s,\"%s\"\n", post, commentid, commenttext
alwaysprinted[commentid] = 1
}
}