You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.6 KiB
61 lines
1.6 KiB
#!/bin/bash |
|
|
|
# to bulk insert, run the following command: |
|
# cat data_mass_insert.txt | redis-cli --pipe |
|
|
|
### Name,RN,Rarity,Sub-Rarity,Gold Price,Item Type,Item Subtype,Attunement,Cursed |
|
### |
|
### redis sets: |
|
### index:dnd:common |
|
### index:dnd:uncommon |
|
### index:dnd:rare |
|
### index:dnd:very_rare |
|
### index:dnd:legendary |
|
### |
|
### redis hash |
|
### dnd:abracadabrus name Abracadabrus rarity Very Rare price 80000 type wondrous item |
|
### dnd:anstruthharp name Anstruth Harp rarity Very Rare price 120000 type wondrous item |
|
### |
|
### .shop will pick between 4-8 commons, uncommons etc. with a chance to roll up to the next qual |
|
|
|
|
|
# read through data |
|
#Abracadabrus,4,Very Rare,A,80000,wondrous item,,, |
|
|
|
while IFS="," read -r name rarity_num item_rarity rec_column4 price type rec_column7 rec_column8 rec_column9 |
|
do |
|
#format name string |
|
formatted=$(echo "$name" | sed 's/[^[:alnum:]]//g') |
|
formatted=${formatted,,} |
|
|
|
### echo "Item: $name" |
|
### echo "Rare #: $rarity_num" |
|
### echo "Rarity: $item_rarity" |
|
### echo "Price: $price" |
|
### echo "Type: $type" |
|
### echo "-----" |
|
|
|
echo "hset dnd:$formatted name '$name' rarity '$item_rarity' price '$price' type '$type'" |
|
case $rarity_num in |
|
1) |
|
echo "SADD index:dnd:common dnd:$formatted" |
|
;; |
|
2) |
|
echo "SADD index:dnd:uncommon dnd:$formatted" |
|
;; |
|
3) |
|
echo "SADD index:dnd:rare dnd:$formatted" |
|
;; |
|
4) |
|
echo "SADD index:dnd:very_rare dnd:$formatted" |
|
;; |
|
5) |
|
echo "SADD index:dnd:legendary dnd:formatted" |
|
;; |
|
*) |
|
echo "TRASH: $name" |
|
;; |
|
esac |
|
|
|
#echo "" |
|
done < <(tail -n +2 data.txt)
|
|
|