Being not very familiar with python, and after carrying out unfruitful long research on internet, I submit to you my problem, hoping favorable reply.

I have a DBF table with geochemical data and I would like writing a script to be integrated in a wider model built with ModelBuilder, and that automatically delete some specific rows, specifically (please see attached example) the rows 1, 2, 4, 5 and 6, while the row 3 (Analyte symbol) is maintained. This is first.

Secondly, I would like to automatically fill in some empty cells in some coloumns (e.g., A, B, C) with the character 0 (zero). Could you please show me the way?


In fact, by deleting rows 1, 2, 4, 5 and 6, I want the row 3 to become the first row (headline) of the table (i.e., Au, Pt, pd, SiO2...). The latter contains 150 rows of data below the 6 first rows, that begins with #59101 in the provided example.

Thus, I do not want to keep just the row 3, but really deleting the rows 1, 2, 4, 5 and 6, so that the row 3 becomes the headline of 150 rows of data (as shown in the herein attached example).

enter image description here


If you want to extract just row 3 and want to keep using ModelBuilder then you'll be wanting something like this:

  1. Create a model with your DBF as one of the inputs
  2. Use the Make Query Table tool or the Select Layer By Attributes tool with the query "\"COLUMN_A\" = 'Analyte Symbol'" (Substitute the real attribute name for COLUMN_A)
  3. Optional: Use Copy Rows to create a new DBF file with only the line you want in it
  4. Feed that table into Iterate Field Values
  5. Feed each field into Get Field Value
  6. Feed the table into Calculate Field with the Field Value as a prerequisite, using a function something like: if FieldValue is not None: return FieldValue else: return 0

That should leave you with a table of just the Analyte Symbols and 0's in the blank spaces.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.