OCaml Forge

Detail: [#1054] Please allow replace not to compare

Feature Requests: Browse | Download .csv | Monitor

[#1054] Please allow replace not to compare

2011-11-08 17:25
Submitted by:
Reuben Thomas (rrt)
Assigned to:
Christophe Troestler (chris)
Operating System:
Please allow replace not to compare

Detailed description
"replace" with some blank marker (`-') for example, or the empty string as the first argument, should simply replace corresponding columns in the first input file with columns from the second. At present it is necessary to introduce a unique ID for each row in each file in order to achieve this result.


Date: 2013-05-11 09:14
Sender: Christophe Troestler

OK. I consider this issue as fixed then. Feel free to reopen it if the proposed solution does not fit your needs.
Date: 2013-05-10 22:01
Sender: Reuben Thomas

You're quite right; I'm sorry for confusing the issue.
Date: 2013-05-10 21:52
Sender: Christophe Troestler

Well, missing columns and empty cells should not be distinguished I think. To start, Csv.compare treats them as equivalent. Also, in the file


is the second element of the second line empty or missing? As the file is written, it is clearly missing but are we sure how all spreadsheets will save these 3 elements? libreoffice for example will write "B1," instead of the second line but the other solution would seem equally sensible.
Date: 2013-05-10 21:44
Sender: Reuben Thomas

I think the spreadsheet metaphor is the right one: pasting an empty entry should overwrite an existing one. I'm sorry, I think my previous comment wasn't clear about that, I was referring to missing columns in the pasted file, not merely empty cells.
Date: 2013-05-10 21:09
Sender: Christophe Troestler

I have released version 1.3.0 which does not require oasis (also in opam). I have reverted the decision of keepinf the old value if the replacement is empty as I found it confusing. Just as it happens with copy/paste in spreadsheets, pasting an empty entry erases the existing one.
Date: 2013-05-10 20:40
Sender: Reuben Thomas

Thanks, I'll look when I can. I first need oasis 0.3, which hasn't yet made it into Debian experimental; I've pinged Sylvain Le Gall about it.
Date: 2013-05-10 18:11
Sender: Christophe Troestler

I have impemented "pastecol" with the semantics you said you want. Please provide feedback.

Date: 2013-05-10 17:26
Sender: Christophe Troestler

Perserving the original value may have strange consequences. For example, one expects

csvtool pastecol 1,2 2,1 a.csv a.csv

to permutes columns 1 and 2 but this is not what will happen if col 2 is missing an element.(because then, the first column value is preserved). Is it the semantic you want?
Date: 2013-05-10 11:29
Sender: Reuben Thomas

I would preserve their original value. I would think of this operation as like pasting into a spreadsheet, with the obvious difference that you can paste a non-contiguous range with a colspec like "1,3-5, 2-".
Date: 2013-05-10 10:39
Sender: Christophe Troestler

If I were to implement column substitution, what would be the meaning of

csvtool replacecol 1,3-5 2- input.csv replace.csv

especially in the case some lines of "replace.csv" do not contain enough columns to replace all "1,3-5"? Do we empty the columns or preserve their original value?
Date: 2013-05-07 22:44
Sender: Reuben Thomas

Thanks, will have a look.
Date: 2013-05-07 22:43
Sender: Christophe Troestler

I have added a "transpose" operation and exposed it in "csvtool". Let me know whether it is enough for you (combined with the replace oparation) or wether you realy need the column replace function (using colspec). [I may implement ot anyway.]
Date: 2013-05-06 23:17
Sender: Reuben Thomas

I think you're right, "replace" is not the right command for this, since it replaces entire rows.

What I wanted to do was to replace the contents of a column (in every row) in old.csv with the contents of the corresponding column from new.csv. I further suggested that this should be done for every column whose name in new.csv matches the name of a column in old.csv.

I think this is like replace, but for columns rather than rows.
Date: 2013-05-06 23:04
Sender: Christophe Troestler

I do not understand what you mean. "csvtool replace" changes ROWS of the original file by the corresponding row in the "update" file provided they agree on the given columns. Could you specify better what the operation should be when "colspec" is "-" ?

Attached Files:


Field Old Value Date By
status_idOpen2013-05-11 09:14chris
close_dateNone2013-05-11 09:14chris
assigned_tonone2013-05-06 23:04chris