Re: change data in large excel file(more than 240 000 rows on sheet)

2015-10-09 Thread gall . pavgal . gall
Thanks Laura!
But i need to change existing excel file and if i use the optimised reader, i 
can read data only, but i can't change data.  
-- 
https://mail.python.org/mailman/listinfo/python-list


win32com.client .Cells

2015-10-09 Thread gall . pavgal . gall
Hi Guys, 

i wrote small function :

Excel = win32com.client.Dispatch("Excel.Application")

excel_book=Excel.Workbooks.Open('D:\WebPython\Config3.xlsx')
s_config=excel_book.Worksheets('VA Prices')

def writtenCell(row,col,value):
 try:
 global s_config
 print "row --> {0}".format(row)
 print "col --> {0}".format(col)
 print "value --> {0}".format(value)
 old_val = s_config.Cells(row+1,col).Value
 s_config.Cells(row+1,col).Value = value
 s_config.Cells(row+1,col).Interior.ColorIndex = 8 # change fon 
color of CELL
 
 except Exception as err: print err

So, it's work :)

But, when i try call this function from Class, i get error :

row --> 36
col --> 18
value --> 34.99
.Cells
row --> 36
col --> 19
value --> 39.99
.Cells
127.0.0.1 - - [09/Oct/2015 21:44:47] "POST /cscox-99988 HTTP/1.1" 500 -
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\flask\app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
  File "C:\Python27\lib\site-packages\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
  File "C:\Python27\lib\site-packages\flask\app.py", line 1403, in 
handle_exception
reraise(exc_type, exc_value, tb)
  File "C:\Python27\lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
  File "C:\Python27\lib\site-packages\flask\app.py", line 1477, in 
full_dispatch_request
rv = self.handle_user_exception(e)
  File "C:\Python27\lib\site-packages\flask\app.py", line 1381, in 
handle_user_exception
reraise(exc_type, exc_value, tb)
  File "C:\Python27\lib\site-packages\flask\app.py", line 1475, in 
full_dispatch_request
rv = self.dispatch_request()
  File "C:\Python27\lib\site-packages\flask\app.py", line 1461, in 
dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
  File "D:\WebPython\new\main.py", line 36, in cust_dir
return define_ID(cscoxId=cscoxId,upload_folder=app.config['UPLOAD_FOLDER'], 
request=request)
  File "D:\WebPython\new\utils.py", line 51, in define_ID
return upload_file(session['customer_dir'][0],request)
  File "D:\WebPython\new\utils.py", line 61, in upload_file
run_exel( 
config_file=session['config_file'],customer_dir=session['customer_dir'][0],customer_file=os.path.join(upload_folder,
 filename),log_name=session['cox_id'])
  File "D:\WebPython\new\utils.py", line 84, in run_exel
customer.merge_to_config()
  File "D:\WebPython\new\main.py", line 119, in merge_to_config
excel_book.Save()
  File "", line 2, in Save

com_error: (-2147221008, 'CoInitialize has not been called.', None, None)

Please, help me! :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: change data in large excel file(more than 240 000 rows on sheet)

2015-10-08 Thread gall . pavgal . gall
thanks Guys!
xlrd it's cool, but i need change existing file, which contains some sheets 
with large data...)
So, if i use xlwt(i.e. create new excel document), i will lose data from other 
sheets.
I tried use openpyxl, but got error :

Traceback (most recent call last):
  File "D:/WebPython/oneMoreTest.py", line 15, in 
wb = load_workbook(filename='D:\WebPython\COX.DSG.Offering Product Catalog 
VANE.xlsx')
  File "C:\Python27\lib\site-packages\openpyxl\reader\excel.py", line 149, in 
load_workbook
_load_workbook(wb, archive, filename, read_only, keep_vba)
  File "C:\Python27\lib\site-packages\openpyxl\reader\excel.py", line 236, in 
_load_workbook
color_index=wb._colors)
  File "C:\Python27\lib\site-packages\openpyxl\reader\worksheet.py", line 327, 
in read_worksheet
fast_parse(ws, xml_source, shared_strings, style_table, color_index)
  File "C:\Python27\lib\site-packages\openpyxl\reader\worksheet.py", line 315, 
in fast_parse
parser.parse()
  File "C:\Python27\lib\site-packages\openpyxl\reader\worksheet.py", line 88, 
in parse
stream = _get_xml_iter(self.source)
  File "C:\Python27\lib\site-packages\openpyxl\reader\worksheet.py", line 36, 
in _get_xml_iter
xml_source = xml_source.encode("utf-8")
MemoryError
-- 
https://mail.python.org/mailman/listinfo/python-list


change data in large excel file(more than 240 000 rows on sheet)

2015-10-07 Thread gall . pavgal . gall
Hi Guys,
I need to change data in large excel file(more than 240 000 rows on sheet), 
it's possible through win32com.client, but i need use Linux OS ...
Please, could you advise some-thing suitable!

best regards, Pavel.
-- 
https://mail.python.org/mailman/listinfo/python-list