diff options
Diffstat (limited to 'makecolumns.sh')
-rwxr-xr-x | makecolumns.sh | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/makecolumns.sh b/makecolumns.sh index b60cfd6..5d2f1aa 100755 --- a/makecolumns.sh +++ b/makecolumns.sh | |||
@@ -29,9 +29,9 @@ main() { | |||
29 | cd work/`basename "${1#white_}"` || exit 1 | 29 | cd work/`basename "${1#white_}"` || exit 1 |
30 | 30 | ||
31 | if [ -f "$1/phonebook.db" ]; then | 31 | if [ -f "$1/phonebook.db" ]; then |
32 | handle_format_version_3 "${1}" | 32 | handle_format_version_4 "${1}" |
33 | elif [ -f ${1}/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] ]; then | 33 | elif [ -f ${1}/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] ]; then |
34 | handle_format_version_2 "${1}" | 34 | handle_format_version_3 "${1}" |
35 | elif [ -n "`find "${1}" -name dpr00000.005 -ls -quit`" ]; then | 35 | elif [ -n "`find "${1}" -name dpr00000.005 -ls -quit`" ]; then |
36 | handle_format_version_1 "${1}" | 36 | handle_format_version_1 "${1}" |
37 | else | 37 | else |
@@ -40,9 +40,9 @@ main() { | |||
40 | cd ../.. | 40 | cd ../.. |
41 | } | 41 | } |
42 | 42 | ||
43 | do_decompress_version_2() { | 43 | do_decompress_version_3() { |
44 | printf "Extracting $2 chunks ... " | 44 | printf "Extracting $2 chunks ... " |
45 | extract_version_2 "${1}" | 45 | extract_version_3 "${1}" |
46 | printf "done.\n" | 46 | printf "done.\n" |
47 | 47 | ||
48 | printf "Decompressing $2 chunks ... " | 48 | printf "Decompressing $2 chunks ... " |
@@ -57,10 +57,10 @@ do_decompress_version_2() { | |||
57 | printf "done.\n" | 57 | printf "done.\n" |
58 | } | 58 | } |
59 | 59 | ||
60 | do_processfile_version_2() { | 60 | do_processfile_version_3() { |
61 | working_on=`basename ${1}` | 61 | working_on=`basename ${1}` |
62 | mkdir $working_on && cd ${working_on} | 62 | mkdir $working_on && cd ${working_on} |
63 | do_decompress_version_2 "${1}" "${2}" | 63 | do_decompress_version_3 "${1}" "${2}" |
64 | cd .. | 64 | cd .. |
65 | 65 | ||
66 | printf "Combining $2 into single file ... " | 66 | printf "Combining $2 into single file ... " |
@@ -109,10 +109,10 @@ handle_format_version_1() { | |||
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | handle_format_version_2() { | 112 | handle_format_version_3() { |
113 | echo "Working on $1. Detected pre-2004 Telefonbuch version." | 113 | echo "Working on $1. Detected pre-2004 Telefonbuch version." |
114 | # Extract teiln.dat | 114 | # Extract teiln.dat |
115 | do_decompress_version_2 $1/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] "teiln.dat" | 115 | do_decompress_version_3 $1/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] "teiln.dat" |
116 | 116 | ||
117 | # See how long each filename is | 117 | # See how long each filename is |
118 | export filename_len=$(( `ls | head -n 1 | wc -c` - 1 )) | 118 | export filename_len=$(( `ls | head -n 1 | wc -c` - 1 )) |
@@ -140,7 +140,7 @@ handle_format_version_2() { | |||
140 | 140 | ||
141 | # Now loop over all files and dump them | 141 | # Now loop over all files and dump them |
142 | printf "Splitting decompressed nname chunks into their columns ... " | 142 | printf "Splitting decompressed nname chunks into their columns ... " |
143 | jot -w %0${filename_len}d - ${nname_file} $(( number_of_files - 1 )) 3 | split_version_2 1 1 | 143 | jot -w %0${filename_len}d - ${nname_file} $(( number_of_files - 1 )) 3 | split_version_3 1 1 |
144 | # set -- `hexdump -n 8 -v -e '" " 1/4 "%u"' ${file}` | 144 | # set -- `hexdump -n 8 -v -e '" " 1/4 "%u"' ${file}` |
145 | # tail -c +$(( $2 + 1 )) ${file} | 145 | # tail -c +$(( $2 + 1 )) ${file} |
146 | # done | tr '\n\0' '\t\n' > 01_02_Flags_Nachname | 146 | # done | tr '\n\0' '\t\n' > 01_02_Flags_Nachname |
@@ -154,7 +154,7 @@ handle_format_version_2() { | |||
154 | printf "done.\n" | 154 | printf "done.\n" |
155 | 155 | ||
156 | printf "Splitting decompress table file chunks into their columns ... " | 156 | printf "Splitting decompress table file chunks into their columns ... " |
157 | jot -w %0${filename_len}d - ${table_file} $(( number_of_files - 1 )) 3 | split_version_2 4 0 | 157 | jot -w %0${filename_len}d - ${table_file} $(( number_of_files - 1 )) 3 | split_version_3 4 0 |
158 | # for file in `jot -w %0${filename_len}d - ${table_file} $(( number_of_files - 1 )) 3`; do | 158 | # for file in `jot -w %0${filename_len}d - ${table_file} $(( number_of_files - 1 )) 3`; do |
159 | # # Offset into first table entry tells us how many | 159 | # # Offset into first table entry tells us how many |
160 | # # fields are in table file | 160 | # # fields are in table file |
@@ -198,7 +198,7 @@ handle_format_version_2() { | |||
198 | # If street names come in an extra file, extract | 198 | # If street names come in an extra file, extract |
199 | # street names first | 199 | # street names first |
200 | streets=$1/[Dd][Aa][Tt]/[Ss][Tt][Rr][Aa][Ss][Ss][Ee][Nn].[Dd][Aa][Tt] | 200 | streets=$1/[Dd][Aa][Tt]/[Ss][Tt][Rr][Aa][Ss][Ss][Ee][Nn].[Dd][Aa][Tt] |
201 | [ -f ${streets} ] && do_processfile_version_2 ${streets} "street name" 99_Strassenname convert_zeros | 201 | [ -f ${streets} ] && do_processfile_version_3 ${streets} "street name" 99_Strassenname convert_zeros |
202 | 202 | ||
203 | # extract street names if 07_unknown contains street indexes | 203 | # extract street names if 07_unknown contains street indexes |
204 | # instead of street names | 204 | # instead of street names |
@@ -213,7 +213,7 @@ handle_format_version_2() { | |||
213 | 213 | ||
214 | karto=$1/[Dd][Aa][Tt]/[Kk][Aa][Rr][Tt][Oo].[Dd][Aa][Tt] | 214 | karto=$1/[Dd][Aa][Tt]/[Kk][Aa][Rr][Tt][Oo].[Dd][Aa][Tt] |
215 | if [ -f ${karto} ]; then | 215 | if [ -f ${karto} ]; then |
216 | do_processfile_version_2 ${karto} "geo coordinates" 90_Geokoordinaten_hnr_raw | 216 | do_processfile_version_3 ${karto} "geo coordinates" 90_Geokoordinaten_hnr_raw |
217 | 217 | ||
218 | printf "Looking up geo coordinates for each phonebook entry ... " | 218 | printf "Looking up geo coordinates for each phonebook entry ... " |
219 | tr '\0' '\n' < 90_Geokoordinaten_hnr_raw | tr ';' '\t' | cut -f "1,2,3,4,6,7" | tr '\n' '\0' > 90_Geokoordinaten_hnr | 219 | tr '\0' '\n' < 90_Geokoordinaten_hnr_raw | tr ';' '\t' | cut -f "1,2,3,4,6,7" | tr '\n' '\0' > 90_Geokoordinaten_hnr |
@@ -223,17 +223,17 @@ handle_format_version_2() { | |||
223 | fi | 223 | fi |
224 | } | 224 | } |
225 | 225 | ||
226 | handle_format_version_3() { | 226 | handle_format_version_4() { |
227 | echo "Working on $1. Detected post-2003 Telefonbuch version." | 227 | echo "Working on $1. Detected post-2003 Telefonbuch version." |
228 | printf "Extracting street names ... " | 228 | printf "Extracting street names ... " |
229 | extract_version_3 $1/streets.tl | 229 | extract_version_4 $1/streets.tl |
230 | 230 | ||
231 | cat file_* | tr '\n\0' '\t\n' > 99_Strassenname | 231 | cat file_* | tr '\n\0' '\t\n' > 99_Strassenname |
232 | rm file_* | 232 | rm file_* |
233 | printf "done.\n" | 233 | printf "done.\n" |
234 | 234 | ||
235 | printf "Extracting phonebook.db ... " | 235 | printf "Extracting phonebook.db ... " |
236 | extract_version_3 $1/phonebook.db | 236 | extract_version_4 $1/phonebook.db |
237 | 237 | ||
238 | rows=`find . -name file_\* | wc -l` | 238 | rows=`find . -name file_\* | wc -l` |
239 | printf "done.\n" | 239 | printf "done.\n" |
@@ -277,7 +277,7 @@ handle_format_version_3() { | |||
277 | 277 | ||
278 | if [ -f $1/zip-streets-hn-geo.tl ]; then | 278 | if [ -f $1/zip-streets-hn-geo.tl ]; then |
279 | printf "Extracting geo coordinates (precision: house number) ... " | 279 | printf "Extracting geo coordinates (precision: house number) ... " |
280 | extract_version_3 $1/zip-streets-hn-geo.tl | 280 | extract_version_4 $1/zip-streets-hn-geo.tl |
281 | cat file_* > 90_Geokoordinaten_hnr | 281 | cat file_* > 90_Geokoordinaten_hnr |
282 | printf "done.\n" | 282 | printf "done.\n" |
283 | printf "Looking up geo coordinates for each phonebook entry ... " | 283 | printf "Looking up geo coordinates for each phonebook entry ... " |
@@ -285,7 +285,7 @@ handle_format_version_3() { | |||
285 | printf "done.\n" | 285 | printf "done.\n" |
286 | elif [ -f $1/zip-streets-geo.tl ]; then | 286 | elif [ -f $1/zip-streets-geo.tl ]; then |
287 | printf "Extracting geo coordinates (precision: street) ... " | 287 | printf "Extracting geo coordinates (precision: street) ... " |
288 | extract_version_3 $1/zip-streets-geo.tl | 288 | extract_version_4 $1/zip-streets-geo.tl |
289 | cat file_* > 91_Geokoordinaten_str | 289 | cat file_* > 91_Geokoordinaten_str |
290 | printf "done.\n" | 290 | printf "done.\n" |
291 | printf "Looking up geo coordinates for each phonebook entry ... " | 291 | printf "Looking up geo coordinates for each phonebook entry ... " |