Comments (4)
To do this I will often add a select
beforehand to duplicate the column and then run a replace
on the duplicated column.
e.g. if my CSV just has two columns and I want to replace something in the second column and store that in a third column with a new name ("Name" here), I might do
cat myfile.csv | gocsv select -c 1,2,2 | gocsv replace -c 3 --regex "Hello, (.*)\!" --repl "\$1" | gocsv rename -c 3 --names Name
I'm not opposed to adding a feature to copy the replaced column into a new column, but I'm not sure what the optimal set of flags should look like for that option.
Do you have any suggestions on how it should look? Would you expect the new column to have the same header name or would you want to be able to specify the header for the new column?
from gocsv.
Yes I've been playing and found the select syntax to duplicate columns.
I hadn't noticed the rename and combining the select and rename clearly works but maybe something like this would be more obvious
gocsv copy -c "ContactName" -name "NewContactName"
The copied field would be appended to the csv row.
from gocsv.
btw: nice tool, saved me hours, so thanks!
from gocsv.
I think the add
subcommand along with the addition of sprig (#28) should handle this case really well now. I'm going to close this.
from gocsv.
Related Issues (20)
- updates to tealeg/xlsx result in gocsv build errors HOT 4
- How to use unique then save as a csv name? HOT 2
- Improving the release practice HOT 3
- "gocsv sql" and column names that contain square brackets? HOT 1
- Convert csv to json HOT 1
- gocsv xlsx option does convert Exel date fields to numbers HOT 1
- add assumes the input has a header HOT 1
- Join Subcommand Problem HOT 1
- The .exe embedded in the installation zip file triggers malware detection in Sophos HOT 3
- Output column raw value HOT 5
- Update Sprig to v3.2.1 HOT 1
- Parse error with escaped quotes HOT 2
- View and getTruncatedLine() have problems
- Cap requires names; panics with only default-name
- Allow to specify encoding and destination path of the output file HOT 1
- How to change to delim from "\x01" to others? HOT 2
- Convert xlsx file from some directory to CSV HOT 9
- Regression in delim's default behavior
- sortable split output files HOT 2
- Convert XLSX to CSV causes blank fields at end of row to not have proper delimiter HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gocsv.