dd06af8866cf7caca22463089b2c78a6cfa60dee
kent
  Sat Aug 31 18:26:33 2019 -0700
Adding -id and -startId options to fieldedTable to get steadily incrementing numerical id's for django.

diff --git src/lib/fieldedTable.c src/lib/fieldedTable.c
index 15a51c1..6a74092 100644
--- src/lib/fieldedTable.c
+++ src/lib/fieldedTable.c
@@ -241,63 +241,81 @@
     }
 
 /* Create fieldedTable . */
 struct fieldedTable *table = fieldedTableNew(reportFileName, fields, fieldCount);
 table->startsSharp = startsSharp;
 while (lineFileRowTab(lf, fields))
     {
     fieldedTableAdd(table, fields, fieldCount, lf->lineIx);
     }
 
 /* Clean up and go home. */
 lineFileClose(&lf);
 return table;
 }
 
-void fieldedTableToTabFile(struct fieldedTable *table, char *fileName)
-/* Write out a fielded table back to file */
+void fieldedTableToTabFileWithId(struct fieldedTable *table, char *fileName, 
+    char *idField, int startId)
+/* Write out a fielded table back to file.  If idField is non-NULL it will be added
+ * to the start of each output line as a steadily incrementing integer starting with startId. */
 {
 FILE *f = mustOpen(fileName, "w");
 
 /* Write out header row with optional leading # */
 if (table->startsSharp)
     fputc('#', f);
+int curId = startId;
 int i;
+if (idField)
+    {
+    fprintf(f, "%s\t", idField);
+    }
 fputs(table->fields[0], f);
 for (i=1; i<table->fieldCount; ++i)
     {
     fputc('\t', f);
     fputs(table->fields[i], f);
     }
 fputc('\n', f);
 
 /* Write out rest. */
 struct fieldedRow *fr;
 for (fr = table->rowList; fr != NULL; fr = fr->next)
     {
+    if (idField)
+	{
+	fprintf(f, "%d\t", curId);
+	curId += 1;
+	}
     fputs(fr->row[0], f);
     for (i=1; i<table->fieldCount; ++i)
 	{
 	fputc('\t', f);
 	fputs(fr->row[i], f);
 	}
     fputc('\n', f);
     }
 
 carefulClose(&f);
 }
 
+void fieldedTableToTabFile(struct fieldedTable *table, char *fileName)
+/* Write out a fielded table back to file */
+{
+fieldedTableToTabFileWithId(table, fileName, NULL, 0);
+}
+
 int fieldedTableMustFindFieldIx(struct fieldedTable *table, char *field)
 /* Find index of field in table's row.  Abort if field not found. */
 {
 int ix = stringArrayIx(field, table->fields, table->fieldCount);
 if (ix < 0)
     errAbort("Field %s not found in table %s", field, table->name);
 return ix;
 }
 
 struct hash *fieldedTableIndex(struct fieldedTable *table, char *field)
 /* Return hash of fieldedRows keyed by values of given field */
 {
 int fieldIx = fieldedTableMustFindFieldIx(table, field);
 struct hash *hash = hashNew(0);
 struct fieldedRow *fr;