Python xlsx reading and pythonxlsx reading
Sample Code
#!/usr/bin/env pythonimport xlrd, sys, re, osworkbook = xlrd.open_workbook( sys.argv[1] )for booksheet in workbook.sheets(): for row in xrange(booksheet.nrows): p = list() i = 0 for col in xrange(booksheet.ncols): cel = booksheet.cell(row, col) val = cel.value try: val = cel.value.encode('utf-8') val = re.sub('\n', '', val) val = re.sub('\s+', '', val) except: pass val = str( val ) p.append(val)0]
Code Functions
Read all the data in the xlxs table in your own form.
Xlrd download and Installation
Xlrd link http://files.cnblogs.com/files/25-to-life/xlrd-0.9.3.tar.gz
Xlrd installation command
tar -xvf xlrd-0.9.3.tar.gz
cd xlrd-0.9.3
sudo python setup.py install
Note:
When the opened file is large, it takes some time.
It is also slow to try other openpyxl packages.
The reason for slowness is that the elements of all cells are parsed by type.