text file to excel(*.txt to *.xls)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sumanthsclsdc
    New Member
    • Oct 2006
    • 3

    text file to excel(*.txt to *.xls)

    hello friends....

    can any one let me know the python code for converting the text file to excel file.

    i require a script to convert sample.txt to sample.xls

    can any one share the code for this.


    regards,
    sumanth
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    You can use pyExcelerator. There is on person that I know of who posts to this forum who is using it. You can get it here.
    Or (if you have excel or open office installed) you can name a tab-delimited text file whatever.xls then
    Code:
    import os
    os.startfile(whatever.xls)
    Then use excel to save it (on Windows of course).

    Comment

    • fuffens
      New Member
      • Oct 2006
      • 38

      #3
      You can also check this previous post:


      BR
      /Fredrik

      Comment

      • true911m
        New Member
        • Dec 2006
        • 92

        #4
        Originally posted by sumanthsclsdc
        hello friends....

        can any one let me know the python code for converting the text file to excel file.

        i require a script to convert sample.txt to sample.xls

        can any one share the code for this.


        regards,
        sumanth
        I was tooling around with pyExcelerator a bit. There are a couple examples with it that are easily reused for simply getting the data into a sheet in a workbook.

        My goal was to use the sheet as an output device that I could format and print from, as well as manipulate, sort of like reportlab for PDF, but not read-only, so more flexible.

        However, if you are satisfied with just getting the data into the spreadsheet, I would also suggest using the CSV modules. I believe they are built-in to later Python versions, so they're more portable if you'll be moving the code around to others' machines. If you create a .CSV and double-click on it in XP, it will open in Excel.

        I'm assuming Windows here, granted, but I would think it could work similarly on other platforms.

        Comment

        Working...