Select to view content in your preferred language

Problem writing all columns with xlwt

1309
1
Jump to solution
05-21-2013 08:52 AM
ChrisBrannin
Regular Contributor
Hello, I am having an issue getting all of the values from my table written into the .xls I can get a single row, but need all of the columns.

# Use row object to get and set field values cur = arcpy.SearchCursor(data_source)   # Set up workbook and sheet book = Workbook() sheet1 = book.add_sheet('Points')   # Set counter rowx = 0   # Loop through rows in dbf file. arcpy.AddMessage(cur) for row in cur:     rowx += 1     # Write each row to the sheet from the workbook. Set column index in sheet for each column in .dbf     sheet1.write(rowx,0,row.ID)     book.save('C:/Output')   print"Export finished" 


In the line
sheet1.write(rowx,0,row.ID)


I need 3 parameters where rowx = walks through and gets all values in every row - 0 = column index of where the values are written in the xls & row.ID = the column that is being written from table.

Any help is greatly appreciated.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ChrisBrannin
Regular Contributor
The simple answer is to just repeat the .write() for each column.

Is there a cleaner way to do this though, anyone?

View solution in original post

0 Kudos
1 Reply
ChrisBrannin
Regular Contributor
The simple answer is to just repeat the .write() for each column.

Is there a cleaner way to do this though, anyone?
0 Kudos