Issue
wb=xw.Book()
for i in ripPaths:
wbtemp=xw.Book(i)
my_values=wbtemp.sheets['sheet1'].range('B5:B4722').options(ndim=2).value
wb.sheets['sheet1'].range("A1:A4722").value=my_values
I am trying to open 100 excel files I have on my disk successively using the for loop, and then copy the same column from each and paste it into another excel file. The problem is that I keep overwriting ColumnA. I need the A1:A4722 in line 5 to increment to B, C, D, through excel column names.
I'm stuck in the mud!
The goal is to take my 100 excel docs with 1 column each to make a new excel file with 100 excel columns. Thanks for any tips.
Solution
wb=xw.Book()
for i in range(3):
wbtemp=xw.Book(ripPaths[i])
my_values=wbtemp.sheets['sheet1'].range('B5:B4722').options(ndim=2).value
wb.sheets.active.range((1,i+1)).value=my_values
Aditya's answer with f strings is sick, but this is smoother. Thanks for the tip, Felix.
Answered By - Rudolf the Reindeer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.