Add CSV fields containing header names, and hash of concatenated data











up vote
-1
down vote

favorite












I have a requirement to concatenate multiple columns dynamically based on header:



Sample input:



id|name|age|gender
10|a|30|m
20|b|20|f


Output:



id|name|age|gender|calculatedcolumns|function
10|a|30|m|id,name|o/pvalue(md5 (10,a))
20|b|20|f|id,name|o/p value(md5 20,b))


Or:



id|name|age|gender|calculatedcolumns|function
10|a|30|m|id,gender|o/pvalue(md5 (10,m))
20|b|20|f|id,gender|o/p value(md5 20,f))


And so on...



so idea here is to pass the column names to be concatenated in an array dynamically and loop through all lines in the file and add two extra columns with contains which columns are being concatenated and whats their hash value.



please advise or point me towards the right approach.



thanks










share|improve this question
























  • What's the difference between o/pvalue and o/p value? Where does the control information about how calculated columns and function come from? There's a lot of missing information here. Please read about how to create an MCVE (Minimal, Complete, and Verifiable example). It is good that you've shown some input and some output; it is a pity that you've not shown all the input information, nor your best effort to solve the problem. We will help fix honest attempts at solving problems; we won't usually write the code for you.
    – Jonathan Leffler
    Nov 11 at 3:21










  • @JonathanLeffler, Thanks for the feed back I will keep in mind whenever i am going to post new questions. also i was not dumping my work on other developers but from my poor framing of the question i can see why you felt so. I did try a few things none of them worked until some one in the community helped me out writing it. This is the code that works for my requirement.ideone.com/T9YNMP
    – kumarm
    Nov 11 at 19:13















up vote
-1
down vote

favorite












I have a requirement to concatenate multiple columns dynamically based on header:



Sample input:



id|name|age|gender
10|a|30|m
20|b|20|f


Output:



id|name|age|gender|calculatedcolumns|function
10|a|30|m|id,name|o/pvalue(md5 (10,a))
20|b|20|f|id,name|o/p value(md5 20,b))


Or:



id|name|age|gender|calculatedcolumns|function
10|a|30|m|id,gender|o/pvalue(md5 (10,m))
20|b|20|f|id,gender|o/p value(md5 20,f))


And so on...



so idea here is to pass the column names to be concatenated in an array dynamically and loop through all lines in the file and add two extra columns with contains which columns are being concatenated and whats their hash value.



please advise or point me towards the right approach.



thanks










share|improve this question
























  • What's the difference between o/pvalue and o/p value? Where does the control information about how calculated columns and function come from? There's a lot of missing information here. Please read about how to create an MCVE (Minimal, Complete, and Verifiable example). It is good that you've shown some input and some output; it is a pity that you've not shown all the input information, nor your best effort to solve the problem. We will help fix honest attempts at solving problems; we won't usually write the code for you.
    – Jonathan Leffler
    Nov 11 at 3:21










  • @JonathanLeffler, Thanks for the feed back I will keep in mind whenever i am going to post new questions. also i was not dumping my work on other developers but from my poor framing of the question i can see why you felt so. I did try a few things none of them worked until some one in the community helped me out writing it. This is the code that works for my requirement.ideone.com/T9YNMP
    – kumarm
    Nov 11 at 19:13













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a requirement to concatenate multiple columns dynamically based on header:



Sample input:



id|name|age|gender
10|a|30|m
20|b|20|f


Output:



id|name|age|gender|calculatedcolumns|function
10|a|30|m|id,name|o/pvalue(md5 (10,a))
20|b|20|f|id,name|o/p value(md5 20,b))


Or:



id|name|age|gender|calculatedcolumns|function
10|a|30|m|id,gender|o/pvalue(md5 (10,m))
20|b|20|f|id,gender|o/p value(md5 20,f))


And so on...



so idea here is to pass the column names to be concatenated in an array dynamically and loop through all lines in the file and add two extra columns with contains which columns are being concatenated and whats their hash value.



please advise or point me towards the right approach.



thanks










share|improve this question















I have a requirement to concatenate multiple columns dynamically based on header:



Sample input:



id|name|age|gender
10|a|30|m
20|b|20|f


Output:



id|name|age|gender|calculatedcolumns|function
10|a|30|m|id,name|o/pvalue(md5 (10,a))
20|b|20|f|id,name|o/p value(md5 20,b))


Or:



id|name|age|gender|calculatedcolumns|function
10|a|30|m|id,gender|o/pvalue(md5 (10,m))
20|b|20|f|id,gender|o/p value(md5 20,f))


And so on...



so idea here is to pass the column names to be concatenated in an array dynamically and loop through all lines in the file and add two extra columns with contains which columns are being concatenated and whats their hash value.



please advise or point me towards the right approach.



thanks







shell






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 0:13









agc

4,6591338




4,6591338










asked Nov 11 at 2:19









kumarm

64




64












  • What's the difference between o/pvalue and o/p value? Where does the control information about how calculated columns and function come from? There's a lot of missing information here. Please read about how to create an MCVE (Minimal, Complete, and Verifiable example). It is good that you've shown some input and some output; it is a pity that you've not shown all the input information, nor your best effort to solve the problem. We will help fix honest attempts at solving problems; we won't usually write the code for you.
    – Jonathan Leffler
    Nov 11 at 3:21










  • @JonathanLeffler, Thanks for the feed back I will keep in mind whenever i am going to post new questions. also i was not dumping my work on other developers but from my poor framing of the question i can see why you felt so. I did try a few things none of them worked until some one in the community helped me out writing it. This is the code that works for my requirement.ideone.com/T9YNMP
    – kumarm
    Nov 11 at 19:13


















  • What's the difference between o/pvalue and o/p value? Where does the control information about how calculated columns and function come from? There's a lot of missing information here. Please read about how to create an MCVE (Minimal, Complete, and Verifiable example). It is good that you've shown some input and some output; it is a pity that you've not shown all the input information, nor your best effort to solve the problem. We will help fix honest attempts at solving problems; we won't usually write the code for you.
    – Jonathan Leffler
    Nov 11 at 3:21










  • @JonathanLeffler, Thanks for the feed back I will keep in mind whenever i am going to post new questions. also i was not dumping my work on other developers but from my poor framing of the question i can see why you felt so. I did try a few things none of them worked until some one in the community helped me out writing it. This is the code that works for my requirement.ideone.com/T9YNMP
    – kumarm
    Nov 11 at 19:13
















What's the difference between o/pvalue and o/p value? Where does the control information about how calculated columns and function come from? There's a lot of missing information here. Please read about how to create an MCVE (Minimal, Complete, and Verifiable example). It is good that you've shown some input and some output; it is a pity that you've not shown all the input information, nor your best effort to solve the problem. We will help fix honest attempts at solving problems; we won't usually write the code for you.
– Jonathan Leffler
Nov 11 at 3:21




What's the difference between o/pvalue and o/p value? Where does the control information about how calculated columns and function come from? There's a lot of missing information here. Please read about how to create an MCVE (Minimal, Complete, and Verifiable example). It is good that you've shown some input and some output; it is a pity that you've not shown all the input information, nor your best effort to solve the problem. We will help fix honest attempts at solving problems; we won't usually write the code for you.
– Jonathan Leffler
Nov 11 at 3:21












@JonathanLeffler, Thanks for the feed back I will keep in mind whenever i am going to post new questions. also i was not dumping my work on other developers but from my poor framing of the question i can see why you felt so. I did try a few things none of them worked until some one in the community helped me out writing it. This is the code that works for my requirement.ideone.com/T9YNMP
– kumarm
Nov 11 at 19:13




@JonathanLeffler, Thanks for the feed back I will keep in mind whenever i am going to post new questions. also i was not dumping my work on other developers but from my poor framing of the question i can see why you felt so. I did try a few things none of them worked until some one in the community helped me out writing it. This is the code that works for my requirement.ideone.com/T9YNMP
– kumarm
Nov 11 at 19:13

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245290%2fadd-csv-fields-containing-header-names-and-hash-of-concatenated-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245290%2fadd-csv-fields-containing-header-names-and-hash-of-concatenated-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

さくらももこ

13 indicted, 8 arrested in Calif. drug cartel investigation