[Devel] r350 - scripts

svn at agendadulibre.org svn at agendadulibre.org
Jeu 10 Juil 09:09:44 CEST 2008


Author: thomas
Date: Thu Jul 10 09:08:24 2008
New Revision: 350

Log:
Autre version du script, non basé sur xls2csv qui est
buggé. Utilisation d'OpenOffice.org Calc à la place (moins pratique,
mais fonctionne).



Modified:
   scripts/extract-cities-coordinates.sh

Modified: scripts/extract-cities-coordinates.sh
==============================================================================
--- scripts/extract-cities-coordinates.sh	(original)
+++ scripts/extract-cities-coordinates.sh	Thu Jul 10 09:08:24 2008
@@ -1,10 +1,5 @@
 #!/bin/sh
 
-if [ ! -x $(which xls2csv) ] ; then
-    echo "Cannot find xls2csv. Please install catdoc package."
-    exit 1
-fi
-
 # Get the source file
 wget http://www.galichon.com/codesgeo/data/ville.zip
 if [ $? -ne 0 ] ; then
@@ -15,8 +10,21 @@
 unzip ville.zip
 rm -f ville.zip
 
-# Extract the XLS file to CSV
-xls2csv ville.xls -c'|' -q0 | \
+# I wish I could use xls2csv, but a bug prevents it do properly
+# extract the specific XLS file we are using. See
+# https://www.wagner.pp.ru/cgi-bin/cvstrac/catdoc/tktview?tn=24
+
+echo "I will start OpenOffice.org Calc."
+echo "Please save the file in CSV format, separated by pipes, with no quotes, under the name ville.csv"
+echo "Press Enter when ready"
+read trash
+
+oocalc ville.xls
+
+echo "Press Enter when done"
+read trash
+
+cat ville.csv | \
     # Remove useless spaces
     sed 's/ *|/|/g;s/^ //'  | \
 
@@ -26,4 +34,4 @@
     # Generate the SQL queries
     sed "s/\([^|]*\)|\([^|]*\)|\([^|]*\)|\([^|]*\)|\([^|]*\)|\([^|]*\)|\([^|]*\)|\([^|]*\)/insert into cities (name,majname,postalcode,inseecode,regioncode,latitude,longitude) values (\"\1\", '\2', '\3', '\4', '\5', '\6', '\7');/" > ville.sql
 
-rm -f ville.xls
\ No newline at end of file
+rm -f ville.xls ville.csv
\ No newline at end of file


Plus d'informations sur la liste de diffusion Devel