-1

A friend of mine has asked me to write a quick Python script. He has a small SQLite database (3 tables) and has to copy a bunch of data to it from an excel spreadsheet. The spreadsheet only has 2 data fields but alot of rows of data. He asked if I would write a quick Python script to transfer the ss data to the db to so he doesn't have to spend a crapload of time manually copying it. I told him that I would do my best. My question is: Where do I start? what do I need to research for this? Does anyone know if there is a pre-existing module to do this? Im trying to research this myself, but haven't come up with anything concrete yet and am not sure of any other search terms to use to narrow down my search. Im just hoping someone wont mind giving my some guidance in the right direction.

Blessings and thanks F

Icsilk
  • 567
  • 1
  • 5
  • 9
  • 1
    I think this shows a real lack of effort on your part. That said, the simplest thing I can think of is save the excel spreadsheet as a CSV and then the ``csv`` module to extract the data, should be a few lines of code. – Gareth Latty Feb 29 '12 at 23:39
  • Its not a lack of effort, Im researching this right now, I thought I would put a post up and maybe get some real-time guidance as to where to look to save some time, instead of researching, possibly coming up empty handed and then posting and having to wait for a response. Im not asking anyone to write it for me, Im just asking for some advice on what I have to learn to get this done. There are vast areas of Python that I am unfamiliar with, and happy to familiarize myself with them. I was just asking what exactly I should familiarize myself with that is project specific. – Icsilk Feb 29 '12 at 23:51
  • 1
    If it's just one spreadsheet (or fewer than about 40), then just save as csv. Then look at the docs for [csv](http://docs.python.org/py3k/library/csv) and [sqlite3](http://docs.python.org/py3k/library/sqlite3). – Thomas K Mar 01 '12 at 00:25

1 Answers1

0

Do you really need Python?

SQLite Database Browser is a freeware, public domain, open source visual tool used to create, design and edit database files compatible with SQLite. Controls and wizards are available for users to:

  • Import and export tables from/to CSV files

If the file is simple enough (no commas in the content), you can import directly from SQLite:

For simple CSV files, you can use the SQLite shell to import the file into your SQLite database.

If you need to import a complex CSV file and the SQLite shell doesn't handle it, you may want to try a different front end, such as SQLite Database Browser.

Emilio Silva
  • 1,942
  • 14
  • 17