MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: cleaning up imported data

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84973] Re: cleaning up imported data
  • From: dh <dh at metrohm.ch>
  • Date: Mon, 21 Jan 2008 06:57:49 -0500 (EST)
  • References: <fmv19h$2md$1@smc.vnet.net>


Hi Tom,

here is a solution using a replacement rule:

YourData //. 

{x1___,x2:{x3___,x0_,___},{x4___,dup,x5___},x6___}/;Dimensions[{x3}]==Dimensions[{x4}]->{x1,x2,{x4,x0,x5},x6}

hope this helps, Daniel



Tom Metcalf wrote:

> 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

> 




  • Prev by Date: Re: List complement operator
  • Next by Date: Re: Help with Eliminate[]
  • Previous by thread: Re: cleaning up imported data
  • Next by thread: Color a Bounding Box Side