Skip to content

--cols-file in fits importer#27

Open
gregreen wants to merge 19 commits into
mjuric:masterfrom
gregreen:master
Open

--cols-file in fits importer#27
gregreen wants to merge 19 commits into
mjuric:masterfrom
gregreen:master

Conversation

@gregreen
Copy link
Copy Markdown

@gregreen gregreen commented May 1, 2018

This pull request adds the ability to specify --cols-file with lsd-import fits. It also fixes a bug that used to occur when a database column name was not recognized.

I had to convert tabs to spaces in order to edit this file, because my text editor wouldn't allow me to write tabs, so that complicates reading the diff.

Comment thread src/lsd/importers/fits.py
dtype = table.dtype.fields[name][0]
setcols[name] = (dtype, dtype.type(val))

# Slurp the columns from file
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of text is taken from the text importer.

Comment thread src/lsd/importers/fits.py Outdated
parser.add_argument('table', help='Name of the table into which to import', type=str)
parser.add_argument('file', help='One or more fits files. If ending in .gz or .bz2, they are assumed to be compressed.', type=str, nargs='+')
parser.add_argument('-c', '--cols', help='Comma separated list of <colname>:<file_column>, where <file_column> is the name of the column in the FITS file that is to be loaded into <colname>.', type=str)
parser.add_argument('--cols-file', help='A file with two, whitespace delimited columns, <colname> <file_column>, having the same meaning as arguments to --cols', type=str)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is taken from the text importer as well. I think this line contains a tab, which will have to be converted to spaces.

Comment thread src/lsd/importers/fits.py
except ValueError:
dbname = fitsname = spec[0]
if dbname not in table.dtype.names:
raise Exception("Unknown column '%s' in table %s" % (dbname, args.table))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a bug here previously, with dbname incorrectly shortened to the non-existent variable name.

@mjuric
Copy link
Copy Markdown
Owner

mjuric commented May 1, 2018

I hate to ask this, but for consistency with the rest of the codebase (and to make the diff more readable) could you switch spaces back to tabs? There's a unix command unexpand (run man unexpand) that should "just work (tm)".

PS: Which editor do you use?

@gregreen
Copy link
Copy Markdown
Author

gregreen commented May 1, 2018

I use vim. It's kind of a pain to switch it to use tabs.

As I'm making changes to the code base, I'm using expand to replace tabs with spaces. I'd hate to go back - spaces display the same everywhere.

@gregreen
Copy link
Copy Markdown
Author

gregreen commented May 1, 2018

I've been trying to make the diffs more readable by doing expand and committing, before making any further changes. I didn't think to do that here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants