Hello, I have a program that generates several 1-dimensional arrays that I would like to conduct data analysis on.

I was wondering if there was some sort of python tool (or module, or anything) that could write these arrays to a column of a spreadsheet ( in OpenOffice formatting).

Is there a way to do this, or would my best bet be to write the arrays to a text file, hope the formatting is okay, and copy paste that into OpenOffice.


Any ideas?

Thanks

Dani AI

Generated

Quick answer: there are three practical ways to get 1‑D arrays into an OpenOffice (ODS) column from Python — (a) export a delimited text file and import (what and hinted at), (b) write a native .ods file from Python (no manual paste), or (c) drive a running LibreOffice/OpenOffice instance for full formatting/control (UNO). If you want a programmatic, repeatable workflow that avoids copy/paste, write a real .ods file with a small ODF library or use the UNO bridge for automation. (pypi.org)

Minimal, practical example (write a Python list as a single column using pyexcel-ods3):

from collections import OrderedDict
from pyexcel_ods3 import save_data

my_array = [3.14, 2.71, 1.41]             # any 1-D iterable
sheet = [[x] for x in my_array]           # convert to rows with one cell each
data = OrderedDict({"Sheet1": sheet})
save_data("column.ods", data)

This produces an .ods with your values down the first column. If your data starts as a NumPy array, convert with array.tolist() first; pyexcel/ezodf handle basic numeric/text cells but won’t preserve Excel-style formatting or charts. (pypi.org)

When to use something else: use ezodf/odfdo/odfpy if you need more control over cell types, templates, or styles; those libraries let you build tables and tweak cell metadata. If you need Calc open and driven (formatting, formulas, printing), use the UNO bridge or a wrapper like PyOO to control LibreOffice programmatically. For heavy numeric workflows where an Excel/XLSX output is acceptable, pandas’ to_excel can be simpler. Common gotchas: Windows can make lxml (a dependency) harder to install, locale decimal separators can change imports/exports, and headless LibreOffice must be started for server automation — test with small files first. (pypi.org)

Notes tied to thread: ’s numpy route is fine for quick CSV/TSV output; if you want the next step (true .ods output or automation) the examples above show a straightforward upgrade from copy/paste.

Recommended Answers

All 3 Replies

OpenOffice will import comma delimited text files, or any other delimiter that you care to choose. If there are commas in the data then use something like comma+space+space as the delimiter. Here is a dated link for creating the spreadsheet in python. It refers to StarOffice (or something like that), which is a former incarnation of OpenOffice, so hopefully this still works. Searching the oooforum will probably yield more hits. Hope this gets you started.

You can try scipy/numpy or pylab (in matplotlib)

numpy.savetxt()

pylab.save()

Member Avatar for Member #322302

If your array is a list, just create a string for each array using "tab.join(array)", then write the string to a sequential file. Use Excel (or whatever the open-office equivalent is) and import it as a tab-delimited text file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.