Giter VIP home page Giter VIP logo

game-database-info's Introduction

Game-database-info

Game database info to be used in creation of xml files or kodi scraper files

Pending information

Data conversion

Bash script to convert csv files to hyperspin style xml. To convert just one csv pass the csv filename to the script. To convert all csv files in a folder run the script with no arguments.

#!/bin/bash
#csv xml function
convcsv2xml()
{
file_in="$1.tmp"
file_out="${1%%.*}.xml"
echo "********************************************"
echo "System:""${1%%.*}"
file_in_csv="$1.tmp.csv"
cp "$1" "$file_in"
cp "$1" "$file_in_csv"

echo "**Cleaning *.csv:"
#clean up csv
#echo 4stars
#sed -i 's~\*\*\*\*~ ~g' "$file_in_csv"
# ** with space
#echo 2stars
#sed -i 's~\*\*~ ~g' "$file_in_csv"
# trailing spaces
echo "Trailing Space"
sed -i 's~ >~>~g' "$file_in_csv"
echo "Trailing Space"
sed -i 's~ >~>~g' "$file_in_csv"

echo "**Cleaning *.xml:"
# & with &
echo "&"
sed -i 's~\&~\&~g' "$file_in"
# ' with '
echo "'"
sed -i "s~'~\'~g" "$file_in"
#  delete "
echo '"'
# : with -
echo ":"
sed -i 's~\:~\-~g' "$file_in"
sed -i 's~"~~g' "$file_in"

# <br><br> with space
echo "<br><br>"
sed -i 's~\<br\>\<br\>~ ~g' "$file_in"
# <br> with space
echo "<br>"
#sed -i 's~\<br\>~ ~g' "$file_in"
# ***** with space
echo "5 stars"
sed -i 's~\*\*\*\*\*~ ~g' "$file_in"
# **** with space
echo "4 stars"
sed -i 's~\*\*\*\*~ ~g' "$file_in"
# *** with space
echo "3 stars"
sed -i 's~\*\*\*~ ~g' "$file_in"
# ** with space
echo "2 stars"
sed -i 's~\*\*~ ~g' "$file_in"
# * with space
echo "1 stars"
sed -i 's~\*~ ~g' "$file_in"
# trailing spaces
echo "Trailing space"
sed -i 's~ >~>~g' "$file_in"
echo "Trailing space"

echo "**Convert *.csv to *.xml"

echo '<?xml version="1.0"?>' > "$file_out"
echo '<menu>' >> "$file_out"
echo '  <header>' >> "$file_out"
echo '    <listname>'${1%%.*}'</listname>' >> "$file_out"
echo '    <lastlistupdate></lastlistupdate>' >> "$file_out"
echo '    <listversion>test</listversion>' >> "$file_out"
echo '    <exporterversion></exporterversion>' >> "$file_out"
echo '  </header>' >> "$file_out"

while IFS=$'>' read -r -a arry
do
  echo '  <game name="'${arry[0]}'">' >> "$file_out"
  echo '    <description>'${arry[1]}'</description>' >> "$file_out"
  echo '    <year>'${arry[2]}'</year>' >> "$file_out"
  echo '    <rating>'${arry[3]}'</rating>' >> "$file_out"
  echo '    <manufacturer>'${arry[4]}'</manufacturer>' >> "$file_out"
  echo '    <dev>'${arry[5]}'</dev>' >> "$file_out"
  echo '    <genre>'${arry[6]}'</genre>' >> "$file_out"
  echo '    <score>'${arry[7]}'</score>' >> "$file_out"
  echo '    <player>'${arry[8]}'</player>' >> "$file_out"
  echo '    <story>'${arry[9]}'</story>' >> "$file_out"
  echo '    <enabled>Yes</enabled>' >> "$file_out" #'${arry[10]}' just set to 'Yes'
  echo '    <crc>'${arry[11]}'</crc>' >> "$file_out"
  echo '    <cloneof>'${arry[12]}'</cloneof>' >> "$file_out"
  echo '  </game>' >> "$file_out"
done < "$file_in"
echo '</menu>' >> "$file_out"

rm "$file_in"
}

if [[ "$1" ]] ; then
	convcsv2xml "$1"
else
	for file in *.csv ; do
		convcsv2xml "$file"
	done
fi
echo "**Moving files"
mkdir -p ./xml\ files
mkdir -p ./tmp
mv *.tmp.csv ./tmp/
mv *.xml ./xml\ files/

game-database-info's People

Contributors

billyc999 avatar teeedubb avatar wintermute0110 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.