Re: Importing data with comma as decimal separator

• To: mathgroup at smc.vnet.net
• Subject: [mg98130] Re: Importing data with comma as decimal separator
• From: Bob F <deepyogurt at gmail.com>
• Date: Tue, 31 Mar 2009 04:16:47 -0500 (EST)
• References: <gqq3sb\$7mt\$1@smc.vnet.net>

```On Mar 30, 3:37 am, Dom <Domagoj.Pavi... at gmail.com> wrote:
> I would like to import two-column numerical data in which comma is
> used as decimal separator. The first 12 lines of the file is header,
> followed by two tab-separated columns of numbers.
> How I can do this in Mathematica 6.0?
> Thanks.

You might try something like this:

Read[str, {Record, Record, Record, Record, Record, Record, Record,
Record, Record, Record, Record, Record}];
str, {Number, Character, Number, Character, Number, Character,
Number}];
Close[str];
For[j = 1, j < Length[datac] + 1, j++, {
a = Part[datac[[j]], 1];
b = Part[datac[[j]], 3];
c = Part[datac[[j]], 5];
d = Part[datac[[j]], 7];
xx[j] = a + b/(10.^(StringLength[ToString[b]])),
yy[j] = c + d/(10.^(StringLength[ToString[d]]));
}]

This assumes the data file has 12 records/lines to ignore, then an
indeterminate amount of data records that have the form (the white
space is a TAB character, ASCII 009)

xxxx,yyyy     xxxxxxx,yyy

and you wanted the data to look like

xxxx.yyyy     xxxxxxx.yyy

I am sure there are lots of ways to do this, so take this into
consideration, when you get 10 different suggestions. HTH.

-Bob

```

• Prev by Date: Graphics and DisplayFunction
• Next by Date: Using manipulate in two cells in one note book crashes my computer.
• Previous by thread: Re: Importing data with comma as decimal separator
• Next by thread: irrational and real exponents