Re: Copying a row from a range of Excel files to another

2019-06-28 Thread Cecil Westerhof
MRAB writes: > On 2019-06-26 22:14, Cecil Westerhof wrote: >> MRAB writes: >> >>> Does Workbook support the 'with' statement? >>> >>> If it does, then that's the best way of doing it. >>> >>> (Untested) >>> >>> with Workbook() as wb_out: >>> for filepath in filepathArr: >>>

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread Sayth Renshaw
Cecil Westerhof wrote: > I was asked to copy a certain line from about 300 Excel lines to a new > Excel file. That is not something I would like to do by hand and I > immediately thought: that should be possible with Python. > > And it is. I was surprised how fast I could write that with openpyx

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread MRAB
On 2019-06-26 22:14, Cecil Westerhof wrote: MRAB writes: Does Workbook support the 'with' statement? If it does, then that's the best way of doing it. (Untested) with Workbook() as wb_out: for filepath in filepathArr: current_row = [] with load_workbook(

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread Cecil Westerhof
MRAB writes: > Does Workbook support the 'with' statement? > > If it does, then that's the best way of doing it. > > (Untested) > > with Workbook() as wb_out: > for filepath in filepathArr: > current_row = [] > > with load_workbook(filepath) as wb_in: >

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread MRAB
On 2019-06-26 13:15, Cecil Westerhof wrote: Cecil Westerhof writes: I was asked to copy a certain line from about 300 Excel lines to a new Excel file. That is not something I would like to do by hand and I immediately thought: that should be possible with Python. And it is. I was surprised ho

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread Cecil Westerhof
Cecil Westerhof writes: > Is it necessary to close the workbooks to circumvent a resource > leak? Still like to know. When not necessary it is better not to cloes them I think. > Is it a problem when a workbook is closed two times? If so I need to > make sure that this is not possible. That i

Re: Copying a row from a range of Excel files to another

2019-06-26 Thread Cecil Westerhof
Cecil Westerhof writes: > I was asked to copy a certain line from about 300 Excel lines to a new > Excel file. That is not something I would like to do by hand and I > immediately thought: that should be possible with Python. > > And it is. I was surprised how fast I could write that with openpyx

Copying a row from a range of Excel files to another

2019-06-26 Thread Cecil Westerhof
I was asked to copy a certain line from about 300 Excel lines to a new Excel file. That is not something I would like to do by hand and I immediately thought: that should be possible with Python. And it is. I was surprised how fast I could write that with openpyxl. My first try was not very neat,