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

Setting default delimiter in .qrc config file? #298

Closed
bigpresh opened this issue May 23, 2022 · 2 comments
Closed

Setting default delimiter in .qrc config file? #298

bigpresh opened this issue May 23, 2022 · 2 comments

Comments

@bigpresh
Copy link

I may be missing something obvious but is there a way to set the default delimiter in the config?

I've tried what seems obvious:

[davidp@supernova:~]$ cat .qrc 
[options]
delimiter=,

but it explodes:

[davidp@supernova:~]$ q -H 'select * from test.csv where col1 = 3'
Traceback (most recent call last):
  File "/usr/bin/q", line 1940, in <module>
    run_standalone()
  File "/usr/bin/q", line 1664, in run_standalone
    default_delimiter = get_option_with_default(
  File "/usr/bin/q", line 1658, in get_option_with_default
    return p.get('options', option).decode('string-escape')
AttributeError: 'str' object has no attribute 'decode'

I almost always use q to query CSV files, and it's a bit annoying to have to tell it every time that the file uses commas as delimiters, otherwise:

[davidp@supernova:~]$ cat test.csv 
"col1","col2"
1,2
3,4
5,6

[davidp@supernova:~]$ q -H 'select * from test.csv where col1 = 3'
Warning: column count is one - did you provide the correct delimiter?
Bad header row: Header must contain only strings and not numbers or empty strings: 'col1,"col2"'
'col1,"col2"': Column name cannot contain commas
@harelba
Copy link
Owner

harelba commented May 23, 2022

Hi,

Thanks for opening this.

Can you check which version of q you're using? It's probably an old one.

The current version is 3.1.6, and contains a fully refactored qrc mechanism.

Here are the relevant links. If things don't work with this new version, please contact me.

Installation Page

Version 3.1.6 Release

@bigpresh
Copy link
Author

Ahhhh.

I'd installed the most recent distro-packed version, both on a Debian box and a Ubuntu 20.04.4 LTS workstation, and both got a much older version:

[davidp@supernova:~]$ q -v
q version 1.8
Copyright (C) 2012-2017 Harel Ben-Attia (harelba@gmail.com, @harelba on twitter)
http://harelba.github.io/q/

Having upgraded them to a non-prehistoric version (3.1.6 from the .deb download), all is well and the config file is recognised and I don't have to supply the delimiter every time.

Thanks for the prompt response, and thanks for a rather awesome tool!

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

No branches or pull requests

2 participants