Open Office and Python

Discussion in 'Python' started by F, Aug 25, 2006.

  1. F

    F Guest

    Hello there!

    I'd like to load a .csv file to the Open Office spreadsheet from the command
    line using an arbitrary delimiter through Python. I don't need any fancy
    formatting and stuff like that, just putting the values in the spreadsheet
    will do.

    Is there a relatively simple way to do that?

    Sorry for the unfocused nature of this question. I wouldn't have asked it if
    this weren't a one-off task and if I didn't need this urgently.

    Any help and pointers would be greatly appreciated.

    Thanks and best regards,

    F.
     
    F, Aug 25, 2006
    #1
    1. Advertising

  2. F

    Ben Sizer Guest

    F wrote:
    > I'd like to load a .csv file to the Open Office spreadsheet from the command
    > line using an arbitrary delimiter through Python. I don't need any fancy
    > formatting and stuff like that, just putting the values in the spreadsheet
    > will do.
    >
    > Is there a relatively simple way to do that?


    I assume when you say load you mean create. To 'load' usually means to
    read data rather than write it. If you want to read the data in, then a
    Google search for "python csv" should answer all your questions.

    Otherwise...

    How are the values stored? It might be as simple as this:

    # sample data
    table = [
    ("item1", 10, 100),
    ("item 2", 15, 300)
    ]

    out = file("my.csv", "w+")
    for row in table:
    out.write(",".join(str(item) for item in row) + "\n")

    And my.csv will look like:
    item1,10,100
    item 2,15,300

    --
    Ben Sizer
     
    Ben Sizer, Aug 25, 2006
    #2
    1. Advertising

  3. On 8/25/06, F <> wrote:
    > I'd like to load a .csv file to the Open Office spreadsheet from the command
    > line using an arbitrary delimiter through Python. I don't need any fancy
    > formatting and stuff like that, just putting the values in the spreadsheet
    > will do.


    Have you looked at the csv module? <http://docs.python.org/lib/module-csv.html>.

    --
    Cheers,
    Simon B,
    ,
    http://www.brunningonline.net/simon/blog/
     
    Simon Brunning, Aug 25, 2006
    #3
  4. F

    tobiah Guest

    F wrote:
    > Hello there!
    >
    > I'd like to load a .csv file to the Open Office spreadsheet from the command
    > line using an arbitrary delimiter through Python.


    I put together a little utility that you may find helpful
    if I understand you correctly. It converts a .csv file
    to a .xls file without the need for the GUI. It makes a
    good guess as to the appropriate column width for each
    column. You could easily fix it to use any delimiter
    as an argument. It's here:

    http://tobiah.org/csv2xls

    It needs PyExcellerator:

    http://sourceforge.net/projects/pyexcelerator

    Tobiah

    --
    Posted via a free Usenet account from http://www.teranews.com
     
    tobiah, Aug 25, 2006
    #4
  5. F

    tobiah Guest

    I should have pointed out that the delimiter is a tab
    right now. That's what I use in general, but I still
    call the files .csv files. Also this doesn't check
    for, or handle quoted fields.

    > I put together a little utility that you may find helpful
    > if I understand you correctly. It converts a .csv file
    > to a .xls file without the need for the GUI.


    --
    Posted via a free Usenet account from http://www.teranews.com
     
    tobiah, Aug 25, 2006
    #5
  6. In <44ef64a2$0$8856$>, tobiah wrote:

    > I should have pointed out that the delimiter is a tab
    > right now. That's what I use in general, but I still
    > call the files .csv files. Also this doesn't check
    > for, or handle quoted fields.


    Why don't you use the `csv` module from the standard library?

    Ciao,
    Marc 'BlackJack' Rintsch
     
    Marc 'BlackJack' Rintsch, Aug 26, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stan Accrington
    Replies:
    1
    Views:
    945
    Michael Borgwardt
    May 13, 2004
  2. Do Re Mi chel La Si Do

    Open-Office ; Python & Win (plain/text)

    Do Re Mi chel La Si Do, Sep 1, 2005, in forum: Python
    Replies:
    0
    Views:
    559
    Do Re Mi chel La Si Do
    Sep 1, 2005
  3. vj
    Replies:
    6
    Views:
    396
    vasudevram
    Nov 18, 2006
  4. Marco Bizzarri

    Re: Python and Open Office

    Marco Bizzarri, Sep 10, 2008, in forum: Python
    Replies:
    9
    Views:
    375
    Hartmut Goebel
    Sep 19, 2008
  5. hackingKK
    Replies:
    0
    Views:
    278
    hackingKK
    Mar 16, 2010
Loading...

Share This Page