in reply to Re: Re: csv output
in thread csv output

Perhaps its because you told Toni to chill out. Toni hasn't posted a single node in this thread except for the original question....

Replies are listed 'Best First'.
Re: Re: Re: Re: csv output
by oubiwann (Sexton) on Mar 15, 2002 at 12:41 UTC
    Then I was completely misunderstood. Look at the threads here - people were criticizing each other's methods. Here's what I was trying to say:

    Hey Toni, it's all tense in here; people are treating this like life and death - when you read this, don't let it reflect on you or your question - just relax, take it with a grain of salt, and come back to us.

    It was precisly for the reason that s/he hadn't posted that I wanted to make this person feel welcome. Was the nature of my post such that it made sense for me to say "hey, man - chill out"? It didn't seem that way to me.

    And now. without waiting for any clarification on my part, I have been given another -1. Does this thing have a monitor? This is just craziness.

Re: Re: Re: Re: csv output
by Anonymous Monk on Mar 15, 2002 at 11:26 UTC
    Thanks for all the responses guys, must admit, i'm a little scared here, didn't mean to wind any one up.
    I guess I should have been a lot clearer from the start. I apologise.
    This is what i'm doing.
    I'm running a microsoft query and I would like to save the file as a csv as I may need to load the contents into a database at some point.

    The code I posted was just a snippet of the program. The only area I am having problems with is the save command which refuses to save as a csv.
    I have looked at the microsoft documentation and tried diff. variations according to the documentation, all to no avail. Again my only issue is with the line that does the save.
    $excel->Application-> SaveAs ({ FileName:="c:/remedy2.csv",FileFormat:=xlCSV }) or warn("Couldnt save file: $!\n");

    Thanks again everyone


    Toni
      My experience is that MS products can't produce a useful CSV file even when you try to export manually from a document created in the product itself (Excel springs to mind).

      So, I'd skip the OLE\Excel steps and go straight for one of the pure Perl solutions mentioned. They are much easier, more controllable, and have a support community...

      Also, it might be helpful for us to see an example record of the type of data you're trying to CSV.

        Could you clarify what you mean by can't produce a useful CSV file?

        My understanding and experience is that Excel generally does a reliable CSV export. Here are the limitations and issues that I know about. It cannot successfully export structure that requires metadata which does not fit in CSV format. (Hardly Excel's fault.) Many people do not know how to parse CSV (split does not cut it, and the interface to Text::CSV makes it impossible to produce a reliable solution). (Again not Excel's fault.) And several years ago they had a bug where positive floating point numbers expressed in scientific notation were not recognizable as being numbers by most other spreadsheets (or Access IIRC). That was their fault, but has long been fixed. And Excel, like most Microsoft products, uses pre-emptive locking, which I find rather irritating and inconvenient. (Not to mention a source of significant trouble from time to time.)

        Are there any other issues that I should be aware of?

      I am sorry for scaring you. I did not intend to. You have a reasonable question, asked in a good way. What bothered me was the quality of the responses that you got. I hold answerers to a higher standard than questioners. As for your more specific question, there are two possible answers.

      One is to use the format_csv function that I gave you, and write a loop where you walk through your data, fetch it into Perl, and then write the file yourself. I would generally suggest doing that, my experience is that it is easier to pull data into Perl and manipulate it in Perl than it is to drive an external application.

      The other is to get the Excel approach working. Not having it available at the moment, I cannot test it. But I can tell you that the error message will not generally be put into $!. Instead you will need to call Win32::OLE::LastError() to get the error message. No promises, but the odds are pretty good that if you check that you will get useful feedback.

      Hey Toni, don't worry about it :-) It may be hard to tell, be we are all on your side.

      With that said, though - I haven't played with OLE in about a year, so I can't tell you anything off the top...

      Thanks for coming back to us :-D If no one has any solutions in the next several posts, I'll check it out when I get home and see if I can help.