-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixedWidth2csv.awk
More file actions
37 lines (28 loc) · 769 Bytes
/
Copy pathfixedWidth2csv.awk
File metadata and controls
37 lines (28 loc) · 769 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
34
35
36
37
BEGIN {
FS = "[\t]";
# Tell compiler that this is an array.
widths[0];
createListArray(widths, 0, 6, 2, 2, 2, 10, 2, 10, 3, 24, 3, 2, 3, 3, 1, 8, 2, 3, 8, 10, 10, 10, 4, 3);
}
# Parse each fixed width line.
{
$0 = parseFixedLine($0, widths);
}
# Check for valid entry.
(integer($1) != 0) {
line = "";
isFirst = 1;
for (i = 1; i <= NF; i++) {
# Skip white space.
if ((i % 2) == 0) {
continue;
}
$i = escapeCsv(trim($i));
if (!isFirst) {
line = line ",";
}
isFirst = 0;
line = line $i;
}
print line;
}