- 论坛徽章:
- 0
|
本帖最后由 hucuibai 于 2014-09-01 17:31 编辑
回复 4# huangxiaohen
用我那个还是不行,数据小的时候可以,多了之后就报错,还有那个pyExcelerator写excel行数是不是有限制,内容多就写不了了最长65535么?
我是直接用mongo.exe执行的脚本,- import os,subprocess
- import json
- class result_query():
-
- def run(self,host,f_name):
- try:
- user='admin'
- password='newbie'
- self.cmd='mongo -u%s -p%s %s:27017/admin <%s'%(user,password,host,f_name)
- p= subprocess.Popen(self.cmd,stdout=subprocess.PIPE, stderr=subprocess.PIPE,shell=True)
- self.error=p.stderr
- return p.stdout
- except Exception,e:
- print 'test:'+str(e)
- def geterror(self):
- return self.error
- app=result_query()
- result=app.run('172.18.72.65','1.txt')
复制代码 之前是用pymongo连接的,后面发现pymongo还是不方便更新和分组都比较麻烦,所以想换成直接执行脚本,但是执行脚本的结果是上面给出的那种格式,这个比较蛋疼,结果有的在一行,有的是分成了几行,所以我就想怎么能弄成一行,把这些结果放到list里面然后我再一个一个显示出来,导到excel表格里面,不然数据不好看,麻烦高手看看,我也是个菜鸟,边看边学,经验少,希望不嫌弃指点一下
excel保存报错
Traceback (most recent call last):
File "C:\Users\hucuibai\Desktop\python_script\test\wxpython_lianxi\main\result\result_data.py", line 103, in dao
w.save('test.xls')
File "C:\Python27\lib\site-packages\pyExcelerator\Workbook.py", line 610, in save
doc.save(filename, self.get_biff_data())
File "C:\Python27\lib\site-packages\pyExcelerator\Workbook.py", line 595, in get_biff_data
data = sheet.get_biff_data()
File "C:\Python27\lib\site-packages\pyExcelerator\Worksheet.py", line 1424, in get_biff_data
result += self.__row_blocks_rec()
File "C:\Python27\lib\site-packages\pyExcelerator\Worksheet.py", line 1333, in __row_blocks_rec
result.append(self.__rows[used_rows].get_row_biff_data())
File "C:\Python27\lib\site-packages\pyExcelerator\Row.py", line 200, in get_row_biff_data
return BIFFRecords.RowRecord(self.__idx, self.__min_col_idx, self.__max_col_idx, height_options, options).get()
File "C:\Python27\lib\site-packages\pyExcelerator\BIFFRecords.py", line 1430, in __init__
options)
struct.error: ushort format requires 0 <= number <= USHRT_MAX
这个应该是限制问题吧,有没有碰到过这种问题的,还有一个就是根据我自己那个方法吧{}里面的内容分出来,但是内容一多就报错
Exception in thread Thread-60:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 551, in __bootstrap_inner
self.run()
File "C:\Python27\lib\threading.py", line 504, in run
self.__target(*self.__args, **self.__kwargs)
File "C:\Users\hucuibai\Desktop\python_script\test\wxpython_lianxi\main\result\result_data.py", line 131, in db_op
data=eval(result_data[cs_start:cs_end+1])
File "<string>", line 1, in <module>
NameError: name 'whatsmyuri' is not defined
|
|