Path: news.mathworks.com!not-for-mail
From: "Ashish Uthama" <first.last@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Textread
Date: Wed, 01 Jul 2009 10:07:51 -0400
Organization: TMW
Lines: 72
Message-ID: <op.uwd6vdw7a5ziv5@uthamaa.dhcp.mathworks.com>
References: <h2favd$6b6$1@fred.mathworks.com>
 <h2feei$qfk$1@fred.mathworks.com>
 <b141dbcd-f862-4480-8dbc-d1651f2f43f4@g19g2000yql.googlegroups.com>
NNTP-Posting-Host: uthamaa.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1246457271 2889 172.31.57.126 (1 Jul 2009 14:07:51 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 1 Jul 2009 14:07:51 +0000 (UTC)
User-Agent: Opera Mail/9.63 (Win32)
Xref: news.mathworks.com comp.soft-sys.matlab:552010


On Wed, 01 Jul 2009 07:00:31 -0400, Rune Allnor <allnor@tele.ntnu.no>  
wrote:

> On 1 Jul, 12:40, "Samuel Dorrell" <sdorr...@asl-vision.co.uk> wrote:
>> "Jesper Lauridsen" <jesperhols...@hotmail.com> wrote in message  
>> <h2favd$6b...@fred.mathworks.com>...
>> > I have a text file with the following data:
>>
>> > 72008,16193        -0,01           0,02            0,015
>> > 72008,16375        -0,029          -0,034          -0,034
>> > 72008,16406        -0,02           -0,054          -0,059
>> > 72008,16437        -0,024          -0,039          -0,039
>> > 72008,16467        0,02            -0,044          -0,044
>> > 72008,16498        -0,005          -0,005          -0,005
>> > 72008,16529        0,034           0,015           0,01
>> > 72008,1656         0,01            0,034           0,034
>> > 72008,16591        0,029           0,01            0,01
>>
>> > I want to load the data in Matlab and replace the comma with dots.  
>> Can I use the textread function and load it into an cell array and  
>> replace the commas with dots or how do I do it?
>>
>> > I would be very happen if somebody could help me:)
>>
>> Does it have to be done in Matlab? Couldn't you open it in a text  
>> editor and use the 'find and replace tool'?
>
> One argument for using matlab would be that the job has
> to be repeated for several files.
>
> These kinds of things often occur because of the locale
> settings on some computer. On one occasion we found this
> very flaw after having delivered hundreds of files to
> a paying client. This was a 24/7 operation, and the flaw
> was discovered just after I had finished my shift. Next
> morning, one guy at the nigh shift had spent 12 hrs
> doing the substitution manually:
>
> - Open the file in an editor
> - Do the find-replace thing
> - Save the file
>
> The only problem was that he had done it in an internal
> database, while it was up to me to hand the corrected
> files to the clients. For bueraucratic reasons, I had
> to either wrap all the newly correcte files (300 if I
> remember correctly) nicley in red tape, or repeat the
> corrections in my archive of files that were already
> 'buearaucratically correct' but which still contained
> the flaw.
>
> So I wrote a matlab script to do the job. It was slow
> compared to the C++ stuff I would have preferred to use,
> but matlab was all I had. I got the job - start writing
> the script to finished conversion - done in less than
> 2 hrs.
>
> Very convenient, when you have a bunch of P-O'd clients
> and bosses hanging around, fuming with rage and
> frustrations.
>
> Rune

Ran into a similar thing once, thankfully our setup had Perl.
perl -p -i.backup -e 's/,/./g' <files>

btw, MATLAB has Perl (!)

  PERL Execute Perl command and return the result.
     PERL(PERLFILE) calls perl script specified by the file PERLFILE
     using appropriate perl executable.