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

csvlook: Change truncation character for floats #941

Closed
csghone opened this issue Mar 9, 2018 · 4 comments
Closed

csvlook: Change truncation character for floats #941

csghone opened this issue Mar 9, 2018 · 4 comments

Comments

@csghone
Copy link

csghone commented Mar 9, 2018

max-column-width does not work on columns interpreted as float.

eg:

echo "2.132456,156548.54646 2.132456,156548.54646" | xargs -n1 |csvlook --max-column-width 10
| 2.132456 | 156548.... |
| -------- | ---------- |
|   2.132… | 156,548... |

Expected behavior (or Workaround):

echo "2.132456,156548.54646 2.132456,156548.54646" | xargs -n1 |csvlook -I --max-column-width 100
| 2.132456 | 156548.54646 |
| -------- | ------------ |
| 2.132456 | 156548.54646 |
@jpmckinney
Copy link
Member

jpmckinney commented Mar 11, 2018

Are you saying that the suggested behavior is to ignore --max-column-width for float columns? 156548.54646 is 12 characters long.

@csghone
Copy link
Author

csghone commented Mar 12, 2018

Sorry. My mistake.
Actually wanted to avoid the ellipsis character generated due to truncation - is there a way to specify a custom truncation character character? I think agate has one, but csvkit doesn't.

Do you prefer to close this ticket and create a new one? Or rename this one.

@jpmckinney jpmckinney changed the title max-column-width is ignored for float Change truncation character for floats Mar 17, 2018
@jpmckinney
Copy link
Member

I renamed the issue. We can implement this by exposing the max_precision parameter of agate's print_table as a command-line argument.

@jwocode
Copy link

jwocode commented Nov 22, 2018

the behaviour changed from csvkit==0.9.1 to csvkit==1.0.2
csvkit==0.9.1 was perfect for me getting exchange-rates from the European Bank. Also the missing column warning did not appear.

with the --no-inference option you can get close to the prior behavior.

before

$ csvsql  --query "select Date,USD,GBP,PLN,JPY from eurofxrefhist  where Date='2016-10-21'" eurofxrefhist.csv   |csvlook 
|-------------+--------+--------+--------+---------|
|  Date       | USD    | GBP    | PLN    | JPY     |
|-------------+--------+--------+--------+---------|
|  2016-10-21 | 1.0886 | 0.8932 | 4.3251 | 112.96  |
|-------------+--------+--------+--------+---------|

now

$ csvsql  --query "select Date,USD,GBP,PLN,JPY from eurofxrefhist  where Date='2016-10-21'" eurofxrefhist.csv   |csvlook 
/usr/lib/python3/dist-packages/agate/utils.py:275: UnnamedColumnWarning: Column 42 has no name. Using "qq".
|       Date |    USD |    GBP |    PLN |    JPY |
| ---------- | ------ | ------ | ------ | ------ |
| 2016-10-21 | 1,089… | 0,893… | 4,325… | 112,96 |

@jpmckinney jpmckinney changed the title Change truncation character for floats csvlook: Change truncation character for floats Oct 17, 2023
@jpmckinney jpmckinney removed this from the Next version milestone Oct 17, 2023
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

3 participants