converting an Excel (xls) file to a comma separated (csv) file without the GUI

前端 未结 13 1699
走了就别回头了
走了就别回头了 2020-12-01 05:29

Is there a simple way to translate an XLS to a CSV formatted file without starting the Excel windowed application?

I need to process some Excel XLS workbooks with sc

相关标签:
13条回答
  • 2020-12-01 06:07

    Use a perl script. Using the Spreadsheet::ParseExcel perl module from CPAN to parse the xls file followed by output as csv should work fine.

    http://search.cpan.org/dist/Spreadsheet-ParseExcel

    You could also try using VBScript.

    0 讨论(0)
  • 2020-12-01 06:07

    iam pretty new to these forums, and it would be nice if they put the year on the time stamps(pet peeve) so i know how old the posts are. iam going to assume they are from 2009.

    but a good solution in python is to use xlrd to read in your xls files. here is a pretty simple intro tutorial: http://scienceoss.com/read-excel-files-from-python/ it isn't mine.

    the only problem i had was excel dates. here is a quick fix for them:

    date = xlrd.xldate_as_tuple( int( sheet.cell( rowNum,colNum ).value ),workBookName.datemode )

    than create a csv file with the inbuilt csv module,as iam a new user i can only post one hyper link. but google the csv module api.

    hope that was helpfull

    0 讨论(0)
  • 2020-12-01 06:11

    VBS script and it works awesome http://www.go4expert.com/forums/showthread.php?t=18188

    Set objArgs = WScript.Arguments For I = 0 to objArgs.Count - 1

    FullName = objArgs(I)
    FileName = Left(objArgs(I), InstrRev(objArgs(I), ".") )
    
    Set objExcel = CreateObject("Excel.application")
    set objExcelBook = objExcel.Workbooks.Open(FullName)
    
    objExcel.application.visible=false
    objExcel.application.displayalerts=false
    
    objExcelBook.SaveAs FileName & "csv", 23
    
    objExcel.Application.Quit
    objExcel.Quit   
    
    Set objExcel = Nothing
    set objExcelBook = Nothing
    

    Next

    0 讨论(0)
  • 2020-12-01 06:14

    From Gnumeric docs:

    Gnumeric can convert files automatically without needing user intervention. This allows a large number of files to be converted using a script. Gnumeric is distributed along with a program called ssconvert which is the program used to convert files automatically. All of the file formats supported by Gnumeric can be used except for the Postscript and PDF file formats which operate through the printing system.

    This application is used, from the command line by specifying, any desired options, an input file and an output file. For example,

    ssconvert myfile.xls myfile.gnumeric
    

    would convert an Excel format file to a Gnumeric format file.

    The available import and export file formats which ssconvert can read can be listed using

    ssconvert --list-importers
    

    or

    ssconvert --list-exporters
    

    respectively.

    Like other GNU command line applications, ssconvert includes a manual page. This page can be accessed by typing:

    man ssconvert
    

    which will open the manual page. This page can be navigated by typing the space bar or using the Page Up and Page Down buttons. The man program can be dismissed by typing the q key.

    I'm using it and works well.

    0 讨论(0)
  • 2020-12-01 06:16

    Use one of portable [Python] libraries:

    pyxlreader.sourceforge.net/

    sourceforge.net/projects/pyexcelerator

    and make extra script layer on top of it.

    0 讨论(0)
  • 2020-12-01 06:17

    @ John Machin: I cant add coment as I newbee for this forum :)

    I didn't use old package pyXLreader but make my post with xlrd in mind ;)

    I saw it month ago but not used in projects.

    WBR

    0 讨论(0)
提交回复
热议问题