Opened 11 years ago

Closed 11 years ago

#4586 closed enhancement (fixed)

XLS: expose row number (as FID?)

Reported by: cdestigter Owned by: warmerdam
Priority: normal Milestone: 1.10.0
Component: OGR_SF Version: 1.9.0
Severity: normal Keywords: xls, xlsx, ods


Background: We're reading an XLS file via OGR. If we encounter issues, we want to report the location to the user in a useful way.

At present there's no way to get hold of the row number for the current feature, which makes this difficult. We considered just keeping track of how many rows have been visited, but that's difficult because OGR skips blank rows (and the header row, if present).

Conceptually the row number seems the same as an FID to me, so perhaps it could be exposed as such?

I presume this is also applicable to XLSX and ODS formats and should be handled similarly. (I haven't yet tried those formats since we're still on 1.9.0)

Change History (5)

comment:1 by Even Rouault, 11 years ago

Hum, I've reviewed quickly the code and I don't see that it will skip empty rows. So, apart from detecting if the field names are of the form FieldXX to know if there's a header line or not, you should be able to use the FID to retrieve the original row in Excel.

comment:2 by Even Rouault, 11 years ago

Ah, I suddenly understand your point. You want the FID to be set to the original row...

comment:3 by cdestigter, 11 years ago

Ah, you're right, it doesn't skip blank rows. Not sure why I thought it did.

So I guess we could work around this by checking if the column names match 'Field[0-9]+', as you pointed out.

I think this is still a useful feature though, because that's a pretty hacky workaround.

comment:4 by Even Rouault, 11 years ago

No, this should be reasonably easy to implement. I'll try to have a look at that

comment:5 by Even Rouault, 11 years ago

Milestone: 2.0.0
Resolution: fixed
Status: newclosed

Fixed in trunk (r24172, r24173) : XLS, XLSX, ODS: set FID to the row number in the spreadsheet software (first row being 1). In case OGR detects a header line, the first feature will then be assigned a FID of 2 (#4586)

Note: See TracTickets for help on using tickets.