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

bcftbx/TabFile: inconsistency when appending columns to TabFile with empty header #179

Open
pjbriggs opened this issue Nov 24, 2020 · 0 comments

Comments

@pjbriggs
Copy link
Member

There appears to be a problem when appending columns to a TabFile which contains data but which doesn't already have any column names assigned.

Example: create a new (empty) TabFile with no header and add a line of data - it reports the number of columns as zero and the header as an empty list:

>>> from bcftbx.TabFile import TabFile
>>> t = TabFile()
>>> t.append(data=[1,2,3])
1	2	3
>>> t.nColumns()
0
>>> t.header()
[]

Now append a new column - only the new column is reported:

>>> t.appendColumn('extra')
>>> t
1	2	3	
>>> t.header()
['extra']

Output the data to stdout:

>>> import sys
>>> t.write(fp=sys.stdout,include_header=True)
#extra
1	2	3	

Add data to the extra column and output to stdout again - now the first column is overwritten:

>>> t[0]['extra'] = 4
>>> t.write(fp=sys.stdout,include_header=True)
#extra
4	2	3	
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant