gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 26af479: Table: descriptive error printed if s


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 26af479: Table: descriptive error printed if sort column has string type
Date: Wed, 21 Aug 2019 17:56:09 -0400 (EDT)

branch: master
commit 26af4796dfc9bab8766240c76bfce5da6835ca97
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Table: descriptive error printed if sort column has string type
    
    Until now, if the column given to Table's `--sort' option was a string
    type, it would crash with a "bug-report" type message, giving a type number
    that is not recognized. This is not understandable to the user. Note that
    this can happen: some FITS tables actually have numbers that are printed as
    strings!!!
    
    With this commit, when the requested column is a string, a desctiptive
    error message is printed, even suggesting ways to fix it.
---
 bin/table/table.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/bin/table/table.c b/bin/table/table.c
index 4c3d163..8640e95 100644
--- a/bin/table/table.c
+++ b/bin/table/table.c
@@ -215,6 +215,22 @@ table_sort(struct tableparams *p)
                       p->cp.minmapsize, p->cp.quietmmap, NULL, NULL, NULL);
   sf=(s=perm->array)+perm->size; do *s=c++; while(++s<sf);
 
+  /* For string columns, print a descriptive message. Note that some FITS
+     tables were found that do actually have numbers stored in string
+     types! */
+  if(p->sortcol->type==GAL_TYPE_STRING)
+    error(EXIT_FAILURE, 0, "sort column has a string type, but it can "
+          "(currently) only work on numbers.\n\n"
+          "TIP: if you know the columns contents are all numbers that are "
+          "just stored as strings, you can use this program to save the "
+          "table as a text file, modify the column meta-data (for example "
+          "to type `i32' or `f32' instead of `strN'), then use this "
+          "program again to save it as a FITS table.\n\n"
+          "For more on column metadata in plain text format, please run "
+          "the following command (or see the `Gnuastro text table format "
+          "section of the book/manual):\n\n"
+          "    $ info gnuastro \"gnuastro text table format\"");
+
   /* Set the proper qsort function. */
   if(p->descending)
     switch(p->sortcol->type)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]