Path: news.mathworks.com!not-for-mail
From: "Laura " <remove.this.laura2820@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Decimals from comma to dot
Date: Tue, 10 Nov 2009 22:28:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 31
Message-ID: <hdcpdh$17j$1@fred.mathworks.com>
References: <gjvfqq$muv$1@fred.mathworks.com> <gk2tkh$64l$1@fred.mathworks.com>
Reply-To: "Laura " <remove.this.laura2820@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257892081 1267 172.30.248.35 (10 Nov 2009 22:28:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 10 Nov 2009 22:28:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1271571
Xref: news.mathworks.com comp.soft-sys.matlab:583993


I also need to get rid of commas, but I'm hoping to find a solution that doesn't overwrite the original file. Does anyone know where I could find that?


"per isakson" <poi.nospam@bimDOTkthDOT.se> wrote in message <gk2tkh$64l$1@fred.mathworks.com>...
> "Fiona Buckley" <buckley_fiona@yahoo.com> wrote in message <gjvfqq$muv$1@fred.mathworks.com>...
> > Hi, 
> > I've got a file in ASCII format with decimal values comma seperated and columns are seperated by tab. The columns either have strings or floating numbers and my first column is in a ISO time-date format.
> > The file to be imported has column headers and titles which I don't need however, I do need all the string data and the floating number data from the general file. 
> > 
> > I want to write a script to import this data, but as the floating points numbers are comma seperated I can't seem to manage. I previously wrote scripts to do this but up to now my decimals were always dot seperated. No matter what I do now I seem to be stuck. Here under some of the many functions I tried and what happened: 
> > A) importdata  - gives me a strucutre with one data field and one textdata field but almost all the strings have been trunckated and the numerical values are combined (i.e. 3,34 6,91 9,32 gives me 3 346 91932)
> > B) fopen - error message saying that the variable is undefined
> > C) textscan or textread - error message as the data is not recognised
> > D) strrep - I can't replace the string as I can't open the file
> > 
> > Does anyone have an idea??? 
> > Cheers
> > Fiona
> 
> One possibility is to run this function as a separate step. It doesn't work with comma separated files and it will replace commas in the header (if there is one) 
> / per
> 
> function    comma2point_overwrite( filespec )
> % replaces all occurences of comma (",") with point (".") in a text-file.
> % Note that the file is overwritten, which is the price for high speed.
>     file    = memmapfile( filespec, 'writable', true );
>     comma   = uint8(',');
>     point   = uint8('.');
>     file.Data( transpose( file.Data==comma) ) = point;
>     delete(file)
> end