ooopy: newbie cannot get basic functionality to work

  • Thread starter Andrew Sackville-West
  • Start date

A

Andrew Sackville-West

Hi list,

I am new to python and old to coding (as in I did it a long time
ago). I've got a task that cries out for a scripted solution --
importing chunks of ASCII data dumps from a point-of-sale system into
an openoffice.org spreadsheet. What a great chance for me to get my
coding skills back and learn python too!

I have attempted to get ooopy to work for me and have run into
problems at the first step. Google returns not much on ooopy and the
common example, from help (OOoPy) is:

| from OOoPy import OOoPy
| >>> o = OOoPy (infile = 'test.sxw', outfile = 'out.sxw')
| >>> e = o.read ('content.xml')
| >>> e.write ()
| >>> o.close ()

okay here goes:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named OOoPy

hmm... okay how about:
['ElementTree', 'OOoElementTree', 'OOoPy', 'StringIO', 'VERSION',
'ZIP_DEFLATED', 'ZipFile', '__builtins__', '__doc__', '__file__',
'__name__', '_autosuper', 'autosuper', 'fromstring', 'mkstemp', 'os']

okay that works. now:
Traceback (most recent call last):

that's not good. at this point, I'm stuck. I've tried various
permutations of this with no other results. It also fails on the
sample file provided with ooopy, test.sxw.

I have seen one solution using zip to get the contents of the oo.o
file which would probably work but would like to figure this out.

I have installed ooopy using setup.py provided with the package on
debian sid, up-to-date. And I've tried it using python 2.3 and 2.4.

any help appreciated. thanks

A
['', '/usr/lib/python24.zip', '/usr/lib/python2.4',
'/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk',
'/usr/lib/python2.4/lib-dynload',
'/usr/local/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages/PIL',
'/var/lib/python-support/python2.4']{'tokenize': <module 'tokenize' from
'/usr/lib/python2.4/tokenize.pyc'>, 'copy_reg': <module 'copy_reg'
from '/usr/lib/python2.4/copy_reg.pyc'>, 'sre_compile': <module
'sre_compile' from '/usr/lib/python2.4/sre_compile.pyc'>,
'ooopy.StringIO': None, '_sre': <module '_sre' (built-in)>,
'__main__': <module '__main__' (built-in)>, 'ooopy.os': None, 'site':
<module 'site' from '/usr/lib/python2.4/site.pyc'>, '__builtin__':
<module '__builtin__' (built-in)>, 'elementtree.ElementTree': <module
'elementtree.ElementTree' from
'/var/lib/python-support/python2.4/elementtree/ElementTree.pyc'>,
'encodings': <module 'encodings' from
'/usr/lib/python2.4/encodings/__init__.pyc'>, 'array': <module 'array'
from '/usr/lib/python2.4/lib-dynload/array.so'>, 'pydoc': <module
'pydoc' from '/usr/lib/python2.4/pydoc.pyc'>, 'posixpath': <module
'posixpath' from '/usr/lib/python2.4/posixpath.pyc'>, '_random':
<module '_random' from '/usr/lib/python2.4/lib-dynload/_random.so'>,
'imp': <module 'imp' (built-in)>, 'tempfile': <module 'tempfile' from
'/usr/lib/python2.4/tempfile.pyc'>, 'errno': <module 'errno'
(built-in)>, 'binascii': <module 'binascii' from
'/usr/lib/python2.4/lib-dynload/binascii.so'>, 'encodings.codecs':
None, 'sre_constants': <module 'sre_constants' from
'/usr/lib/python2.4/sre_constants.pyc'>, 're': <module 're' from
'/usr/lib/python2.4/re.pyc'>, 'encodings.latin_1': <module
'encodings.latin_1' from '/usr/lib/python2.4/encodings/latin_1.pyc'>,
'collections': <module 'collections' from
'/usr/lib/python2.4/lib-dynload/collections.so'>, 'os.path': <module
'posixpath' from '/usr/lib/python2.4/posixpath.pyc'>, '_codecs':
<module '_codecs' (built-in)>, 'opcode': <module 'opcode' from
'/usr/lib/python2.4/opcode.pyc'>, 'encodings.exceptions': None, 'sre':
<module 'sre' from '/usr/lib/python2.4/sre.pyc'>, 'math': <module
'math' from '/usr/lib/python2.4/lib-dynload/math.so'>, 'fcntl':
<module 'fcntl' from '/usr/lib/python2.4/lib-dynload/fcntl.so'>,
'stat': <module 'stat' from '/usr/lib/python2.4/stat.pyc'>,
'zipimport': <module 'zipimport' (built-in)>, 'string': <module
'string' from '/usr/lib/python2.4/string.pyc'>, 'inspect': <module
'inspect' from '/usr/lib/python2.4/inspect.pyc'>, 'warnings': <module
'warnings' from '/usr/lib/python2.4/warnings.pyc'>, 'encodings.types':
None, 'UserDict': <module 'UserDict' from
'/usr/lib/python2.4/UserDict.pyc'>, 'ooopy.Version': <module
'ooopy.Version' from '/usr/lib/python2.4/ooopy/Version.py'>,
'zipfile': <module 'zipfile' from '/usr/lib/python2.4/zipfile.pyc'>,
'repr': <module 'repr' from '/usr/lib/python2.4/repr.pyc'>, 'sys':
<module 'sys' (built-in)>, 'ooopy.elementtree': None,
'ooopy.tempfile': None, 'itertools': <module 'itertools' from
'/usr/lib/python2.4/lib-dynload/itertools.so'>, 'codecs': <module
'codecs' from '/usr/lib/python2.4/codecs.pyc'>, 'readline': <module
'readline' from '/usr/lib/python2.4/lib-dynload/readline.so'>,
'elementtree': <module 'elementtree' from
'/var/lib/python-support/python2.4/elementtree/__init__.pyc'>,
'ooopy.OOoPy': <module 'ooopy.OOoPy' from
'/usr/lib/python2.4/ooopy/OOoPy.py'>, 'types': <module 'types' from
'/usr/lib/python2.4/types.pyc'>, 'struct': <module 'struct' from
'/usr/lib/python2.4/lib-dynload/struct.so'>, 'elementtree.string':
None, 'thread': <module 'thread' (built-in)>, 'StringIO': <module
'StringIO' from '/usr/lib/python2.4/StringIO.pyc'>, 'ooopy.zipfile':
None, 'strop': <module 'strop' from
'/usr/lib/python2.4/lib-dynload/strop.so'>, 'signal': <module 'signal'
(built-in)>, 'zlib': <module 'zlib' from
'/usr/lib/python2.4/lib-dynload/zlib.so'>, 'elementtree.ElementPath':
<module 'elementtree.ElementPath' from
'/var/lib/python-support/python2.4/elementtree/ElementPath.pyc'>,
'random': <module 'random' from '

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFFe3SUaIeIEqwil4YRAmPgAJ9a+MmSTfIU9C7AO5yl90VDUaJJGQCgy6Ar
13AqgM/YMlOfnGoEEIeRHl4=
=h+4B
-----END PGP SIGNATURE-----
 
Ad

Advertisements

P

Paul Watson

Andrew said:
Hi list,

I am new to python and old to coding (as in I did it a long time
ago). I've got a task that cries out for a scripted solution --
importing chunks of ASCII data dumps from a point-of-sale system into
an openoffice.org spreadsheet. What a great chance for me to get my
coding skills back and learn python too!

The openoffice.org spreadsheet tool can read a CSV file. How about
producing that first, just so you have something that works. I agree,
this sounds like a nice way to dive into Python, but you might want
something that works first, even if it is not elegant.
 
A

Andrew Sackville-West

The openoffice.org spreadsheet tool can read a CSV file. How about
producing that first, just so you have something that works. I agree,
this sounds like a nice way to dive into Python, but you might want
something that works first, even if it is not elegant.

absolutely a good idea. I'm just thinking back to when I automated
this under windows/quattro pro/whatever-corel's-script is and wanted
to return those blissful days.

But I suppose, modularising the thing properly, I could but whatever
"backend" into it I want. (seems funny to use the idea of a backend
with something so trivial.

And I still want to get ooopy working. I feel there is something
simple and fundamental I am missing here in getting this working at
the most basic level.

thanks

A

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFFe4ZcaIeIEqwil4YRAnyGAJ9anrY2jhNgDFm18seaIkbZ8I4QfgCcC8cN
FVkkdjAtuVanGL8OQ0J+xEM=
=D5VI
-----END PGP SIGNATURE-----
 
J

John Machin

Andrew said:
Hi list,

I am new to python and old to coding (as in I did it a long time
ago). I've got a task that cries out for a scripted solution --
importing chunks of ASCII data dumps from a point-of-sale system into
an openoffice.org spreadsheet. What a great chance for me to get my
coding skills back and learn python too!

I have attempted to get ooopy to work for me and have run into
problems at the first step. Google returns not much on ooopy and the
common example, from help (OOoPy) is:

| from OOoPy import OOoPy
| >>> o = OOoPy (infile = 'test.sxw', outfile = 'out.sxw')
| >>> e = o.read ('content.xml')
| >>> e.write ()
| >>> o.close ()

okay here goes:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named OOoPy

hmm... okay how about:
['ElementTree', 'OOoElementTree', 'OOoPy', 'StringIO', 'VERSION',
'ZIP_DEFLATED', 'ZipFile', '__builtins__', '__doc__', '__file__',
'__name__', '_autosuper', 'autosuper', 'fromstring', 'mkstemp', 'os']

okay that works. now:
Traceback (most recent call last):

OK, so that tells you that ooopy.OOoPy is a *module*, and it contains
*another* gizmoid named OOoPy.

[snip]
[snip]
'ooopy.OOoPy': <module 'ooopy.OOoPy' from
'/usr/lib/python2.4/ooopy/OOoPy.py'>,

Uh-huh. Confirmation that ooopy.OOoPy is a module.

Try:

from ooopy import OOoPy
o = OOoPy.OOoPy(infile='/home/andrew/monthly.ods')

BTW, is that package being maintained? Did you ask the maintainer? Any
response?

HTH,
John
 
Ad

Advertisements

A

Andrew Sackville-West

OK, so that tells you that ooopy.OOoPy is a *module*, and it contains
*another* gizmoid named OOoPy.

ah ha! I knew it was something fundamental. its those technical terms
that throw me ;-) (gizmoid).
[snip]
sys.modules
[snip]
'ooopy.OOoPy': <module 'ooopy.OOoPy' from
'/usr/lib/python2.4/ooopy/OOoPy.py'>,

Uh-huh. Confirmation that ooopy.OOoPy is a module.

Try:

from ooopy import OOoPy
o = OOoPy.OOoPy(infile='/home/andrew/monthly.ods')

BTW, is that package being maintained? Did you ask the maintainer? Any
response?

I wondered about that when I was looking at it. It was last updated
about a year ago which isn't bad as far as some projects go... heh. No
I didn't go after the maintainer. I'm also looking at maybe using
ElementTree directly as ooopy is a pretty thin wrapper anyway.

anyway, thanks for the help. I can now do fun things like for n in
o.getiterator(): and so forth.

A

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFFe6QBaIeIEqwil4YRAqmNAKDEtVsTJrpBBmOf7XPnr/O6KapVZwCgxxv1
ymEWF68pQ5exK9RA34cIu0U=
=JOoq
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top