cleaning up imported data
- To: mathgroup at smc.vnet.net
- Subject: [mg84932] cleaning up imported data
- From: Tom Metcalf <thmetcalf at mac.com>
- Date: Sun, 20 Jan 2008 03:34:52 -0500 (EST)
I'm importing some data files (into Mathematica 6) that a colleague prepared, where each line of the original data file represents a data point, with several parameters recorded for each data point. The problem is that for some of these data points, he used ditto marks to specify that the value of a particular field is the same as the one from the record above, and there are stretches with many ditto marks in a row. I want to convert the ditto marks to the real values, which I did with the following Do loop, but the Do loop seems so... un-Mathematica-ish and I'm wondering if there's a more elegant way to accomplish the task. hdA = Import[filename, "TSV"]; dup = hdA[[3,2]] (* manually set the ditto mark character *) Do[hdA[[i, j]] = If[hdA[[i, j]] == dup, hdA[[i - 1, j]], hdA[[i, j]]], {i, Length[hdA]}, {j, Length[hdA[[2]]]}] --Tom Metcalf