[xlrd] sanitize the output and store in a 2d arrays
Jay Jesus Amorin
jay.amorin at gmail.com
Tue Jan 27 11:41:11 EST 2009
Hi gurus,
Script:
#!/usr/bin/python
import xlrd, sys
def main(toParse):
workBook = xlrd.open_workbook(toParse)
mySheet = workBook.sheet_by_index(0)
for rownum in range(mySheet.nrows):
print mySheet.row_values(rownum)
if __name__ == '__main__':
if len(sys.argv) < 2:
sys.stderr.write("Usage: %s EXCEL.XLS\n" % (sys.argv[0]))
else:
main(sys.argv[1])
Output:
myuser at testsvr:~> ./parse.py test.xls
*[u'*thisislineone*'*, 343*.0]*
*[u'*thisislinetwo*'*, 344*.0]*
*[u'*thisislinethree*'*, 345*.0]*
This is the content of my test.xls:
thisislineone 343
thisislinetwo 344
thisislinethree 345
How do i remove the bold part of the output (*[u'*. *'* and *.0]* and store
the output in a 2 dimensional array?
Many thanks.
PythonNewbie,
Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090128/6d504e40/attachment.html>
More information about the Python-list
mailing list