187 |
""" |
""" |
188 |
return self.column_map.has_key(col) |
return self.column_map.has_key(col) |
189 |
|
|
190 |
def ReadRowAsDict(self, row): |
def RowIdToOrdinal(self, gid): |
191 |
"""Return the entire row as a dictionary with column names as keys""" |
"""Return the row ordinal given its id |
192 |
|
|
193 |
|
Since for DBFTables the row id is the row number, return the |
194 |
|
value unchanged. |
195 |
|
""" |
196 |
|
return gid |
197 |
|
|
198 |
|
def RowOrdinalToId(self, num): |
199 |
|
"""Return the rowid for given its ordinal |
200 |
|
|
201 |
|
Since for DBFTables the row id is the row number, return the |
202 |
|
value unchanged. |
203 |
|
""" |
204 |
|
return num |
205 |
|
|
206 |
|
def ReadRowAsDict(self, row, row_is_ordinal = 0): |
207 |
|
"""Return the entire row as a dictionary with column names as keys |
208 |
|
|
209 |
|
The row_is_ordinal is ignored for DBF tables because the row id |
210 |
|
is always the row number. |
211 |
|
""" |
212 |
return self.dbf.read_record(row) |
return self.dbf.read_record(row) |
213 |
|
|
214 |
def ReadValue(self, row, col): |
def ReadValue(self, row, col, row_is_ordinal = 0): |
215 |
"""Return the value of the specified row and column |
"""Return the value of the specified row and column |
216 |
|
|
217 |
The col parameter may be the index of the column or its name. |
The col parameter may be the index of the column or its name. |
218 |
|
|
219 |
|
The row_is_ordinal is ignored for DBF tables because the row id |
220 |
|
is always the row number. |
221 |
""" |
""" |
222 |
return self.dbf.read_record(row)[self.column_map[col].name] |
return self.dbf.read_record(row)[self.column_map[col].name] |
223 |
|
|
354 |
"""Return the number of rows in the table""" |
"""Return the number of rows in the table""" |
355 |
return len(self.data) |
return len(self.data) |
356 |
|
|
357 |
def ReadValue(self, row, col): |
def RowIdToOrdinal(self, gid): |
358 |
|
"""Return the row ordinal given its id |
359 |
|
|
360 |
|
Since for MemoryTables the row id is the row number, return the |
361 |
|
value unchanged. |
362 |
|
""" |
363 |
|
return gid |
364 |
|
|
365 |
|
def RowOrdinalToId(self, num): |
366 |
|
"""Return the rowid for given its ordinal |
367 |
|
|
368 |
|
Since for MemoryTables the row id is the row number, return the |
369 |
|
value unchanged. |
370 |
|
""" |
371 |
|
return num |
372 |
|
|
373 |
|
def ReadValue(self, row, col, row_is_ordinal = 0): |
374 |
"""Return the value of the specified row and column |
"""Return the value of the specified row and column |
375 |
|
|
376 |
The col parameter may be the index of the column or its name. |
The col parameter may be the index of the column or its name. |
377 |
|
|
378 |
|
The row_is_ordinal is ignored for DBF tables because the row id |
379 |
|
is always the row number. |
380 |
""" |
""" |
381 |
return self.data[row][self.column_map[col].index] |
return self.data[row][self.column_map[col].index] |
382 |
|
|
383 |
def ReadRowAsDict(self, index): |
def ReadRowAsDict(self, index, row_is_ordinal = 0): |
384 |
"""Return the entire row as a dictionary with column names as keys""" |
"""Return the entire row as a dictionary with column names as keys |
385 |
|
|
386 |
|
The row_is_ordinal is ignored for DBF tables because the row id |
387 |
|
is always the row number. |
388 |
|
""" |
389 |
return dict([(col.name, self.data[index][col.index]) |
return dict([(col.name, self.data[index][col.index]) |
390 |
for col in self.columns]) |
for col in self.columns]) |
391 |
|
|