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

mutate2 concatenate strings without string evaluation #46

Closed
avilella opened this issue Jun 20, 2018 · 2 comments
Closed

mutate2 concatenate strings without string evaluation #46

avilella opened this issue Jun 20, 2018 · 2 comments

Comments

@avilella
Copy link

I have an example .csv with the values:

patient_id,frequency
102900008,2
102100016,2

And I want to create two more columns like so:

patient_id,frequency,extraction_from_sample_name,extraction_to_sample_name
102900008,2,102900008pool,102900008xt
102100016,2,102100016pool,102100016xt

In trying to append the "pool" to the patient_id, it evaluates it as a number, and changes it to scientific notation, see below. How can I avoid this and simply get the string as text?

cat example.csv | csvtk mutate2 -n extraction_from_sample_name -e ' $patient_id + "pool"'
patient_id,frequency,extraction_from_sample_name
102900008,2,1.02900008e+08pool
102100016,2,1.02100016e+08pool
shenwei356 added a commit that referenced this issue Jun 21, 2018
@shenwei356
Copy link
Owner

shenwei356 commented Jun 21, 2018

Hi Albert, the reason is that 102900008 is too large and been converted in scientific notation.

It's hard to make the conversion smart for multiple scenes, so I add an option -s/--digits-as-string to fix this, check v0.15.0-dev.

$ cat example.csv | csvtk mutate2 -n extraction_from_sample_name -e ' $patient_id + "pool"' -s
patient_id,frequency,extraction_from_sample_name
102900008,2,102900008pool
102100016,2,102100016pool

@avilella
Copy link
Author

Tested and it works like a charm. Thanks for the speedy reply!

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