summaryrefslogtreecommitdiff
path: root/src/makecolumns.sh
blob: 1faa8765c5790f5bcdaecdb6092c3c72aeb2396d (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh

EL=`dirname $0`/../bin/el
HO=`dirname $0`/../bin/hexout

if [ $# -ne 2 ]; then
  echo "Syntax: $0 [phonebookdirectory]"
  exit 1
fi

make -f Makefile all

../bin/decompress $1/streets.tl

cat file_* > streets
rm file_*

../bin/decompress $1/phonebook.db

numfiles=`find . -name file_\* | wc -l`

for column in `jot - 0 11 1`; do
  for file in `jot - ${column} ${numfiles} 11`; do
    acton=`printf file_%05x ${file}`
    if [ ${column} = 0 ]; then
      ${HO} < ${acton} >> column_0;
    else
      tr '\0' '\n' < ${acton} >> column_${column};
    fi
 done;
done

mv column_0 01_Flags
mv column_1 02_Nachname
mv column_2 03_Vorname
mv column_3 04_05_Namenszusatz_Addresszusatz
mv column_4 09_Detail
mv column_5 07_08_Strassenindex_Hausnummer
mv column_6 12_Vorwahl
mv column_7 10_Postleitzahl
mv column_8 11_Ort
mv column_9 13_Rufnummer
mv column_10 14_15_Email_Webadresse

[ -e streets ] && mv streets 99_Strassenname

if [ -e 99_Strassenname ]; then
  cut -f 1 07_08_Strassenindex_Hausnummer | ${EL} -0 99_Strassenname > 07_Strasse
else
  echo Could not convert streetindexes
fi

find . -name file_\* -delete