Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--cols-file in fits importer #27

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Conversation

gregreen
Copy link

@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.

dtype = table.dtype.fields[name][0]
setcols[name] = (dtype, dtype.type(val))

# Slurp the columns from file
Copy link
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.

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
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.

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
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
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
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
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