On 13-Jun-11 11:02:16, Brett Parker wrote:
On 13 Jun 11:37, Richard Parsons wrote:
Brett Parker iDunno@sommitrealweird.co.uk wrote:
So, what I'd be looking at is:
Table : Brewery Columns: id name description Table : Beer Columns: id brewery_id name description
That looks much better to me. Now you need to write some sql that creates that database. Have a look at the sqlite documentation for that.
Thus having a one to many relationship between brewery and beer, storing the id of the brewery in the beer means that you can change the fields of the brewery (in the event of it being renamed, or the description changing, etc), and that applies immediately to all beers of the brewery.
This is normal database normalisation.
That's a mouthful. :)
Now back to your original question. Can you convert the spreadsheet to csv? That will make it easier to parse. Perhaps then give the first few lines of that csv, so we can help with parsing it.
Also, which scripting language do you want to do this in? Bash is probably easiest for me. Python will do it easily enough. Perl can do it, but I don't know perl (others on the list probably do). Someone suggested awk: that would probably be neater that bash/python, but I'm sure not as experienced in it. I'm sure there's lots more options (ruby etc).
I would *never* suggest parsing csv in bash. Ever. Python's csv module is lovely, and perl's DBD::CSV is fine. Awk hasn't got a csv parser,
Err, I respectfully disagree ... (in other words, b*****ks)!
Copy the following into a console:
awk 'BEGIN{FS=","; i=0}; {i=i+1; print $i}' << EOT Row 1,Field 1.1,Field 1.2,Field 1.3 Row 2,Field 2.1,Field 2.2,Field 2.3 Row 3,Field 3.1,Field 3.2,Field 3.3 Row 4,Field 4.1,Field 4.2,Field 4.3 EOT
and you will get:
Row 1 Field 2.1 Field 3.2 Field 4.3
(printing field i=1 from line 1, field i=2 from line 2, ... ).
So awk has parsed the CSV! The trick is to set the Field Separator (FS=",") to comma. After that you can do what you like.
Ted.
and reinvention of wheels is bad :)
It appears that there are python modules for interactive with openoffice, but I've not played with them yet, so I can't recommend them. Certainly previously when faced with a similar situation I've gone the csv and python route because it was the path of least resistance (and I was in a hurry...) -- Brett Parker
-------------------------------------------------------------------- E-Mail: (Ted Harding) ted.harding@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 13-Jun-11 Time: 12:35:30 ------------------------------ XFMail ------------------------------