Skip to content

Commit 9dc914a

Browse files
update tests and headers
1 parent a02ac7a commit 9dc914a

File tree

6 files changed

+84
-11
lines changed

6 files changed

+84
-11
lines changed

fileToSqliteTable.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
INPUT=
3+
if [ ! -t 0 ]; then
4+
IFS='' read -d '' -r INPUT
5+
echo -n "${INPUT}"
6+
fi
7+
if [ ! -z "$1" ]; then
8+
params=("$@")
9+
for i in "${params[@]}"; do
10+
echo -n "$i"
11+
done
12+
fi

labelsToLines.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
INPUT=
3+
if [ ! -t 0 ]; then
4+
IFS='' read -d '' -r INPUT
5+
echo -n "${INPUT}"
6+
fi
7+
if [ ! -z "$1" ]; then
8+
# Script to split a string based on the delimiter
9+
if [ -r "$1" ]; then
10+
header=$(head -n 1 $1)
11+
params=($(echo $header | tr "," "\n"))
12+
#Print the split string
13+
[ ! -z "$2" ] && [ ! -r "$2" ] && echo -n "" > $2
14+
for i in "${params[@]}"
15+
do
16+
echo $i
17+
[ -r "$2" ] && echo $i >> $2
18+
#echo -n "$i"
19+
done
20+
fi
21+
fi

test.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
PATH,PRICE,CURRENCY
2+
Faktura_FP_676_1_2020.pdf,2.74,EUR
3+
RG_100067031335.pdf,0.84,EUR

test.sh

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
#!/bin/bash
2-
## prepare example of file: index.html
3-
curl "https://softreck.com" --silent -o index.html
2+
# CONTRIBUTION
3+
## Author: Tom Sapletta
4+
## Created Date: 25.07.2022
5+
46
echo ""
7+
if [ -z "$1" ]; then
8+
ls -1 test/
9+
exit
10+
fi
511

6-
## Test
12+
testFile() {
13+
echo $1
14+
echo "# TEST"
15+
echo "FILE: $1"
16+
cat test/$1
17+
echo ""
18+
echo "OUTPUT:"
19+
sh test/$1
20+
echo ""
21+
}
22+
## Test One
23+
if [ -r "test/$1" ]; then
24+
testFile $1
25+
exit
26+
fi
27+
## Test ALL
728
TEST_FILE_LIST=$(ls test)
829
for FILE in $TEST_FILE_LIST
930
do
10-
echo "# TEST"
11-
echo "FILE: $FILE"
12-
cat test/$FILE
13-
echo ""
14-
echo "OUTPUT:"
15-
sh test/$FILE
16-
echo ""
17-
done
31+
testFile $FILE
32+
done

test/fileToSqliteTable.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
./fileToSqliteTable.sh "test.csv" "Tablename" "db.sqlite"
3+
./fileAsTableOnSqlite.sh "test.csv" "Tablename" "db.sqlite"
4+
./csvFileAsTableOnSqlite.sh "test.csv" "Tablename" "db.sqlite"
5+
./mapCsvFileTOSqlite.sh "map.csv" "test.csv" "db.sqlite"
6+
7+
8+
CSV_COL,SQL_COLUMN,TYPE
9+
10+
11+
12+
SOURCE_COL,TARGET_COL
13+
14+
TARGET_COL, TARGET_TYPE
15+
16+

test/labelsToLines.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
./labelsToLines.sh "test.csv" "header.txt"
3+
4+
5+
6+

0 commit comments

Comments
 (0)