Prev: Flight gear Simulink
Next: error saving figure
From: Jake the Snake on 3 Oct 2006 22:57 Hello, I have a huge amount of numbers in a .txt file. The numbers are in the form 2,43252e+1. I need to replace the , with . How should I do this? I'd prefer some import method that does this during the import procedure. -Janne
From: Tobias on 5 Oct 2006 05:42 Hi, I guess you import the data as text and convert it then to numbers. Try 'strrep' before you convert the text to numbers. Tobias Jake the Snake schrieb: > Hello, > > I have a huge amount of numbers in a .txt file. The numbers are in the form 2,43252e+1. I need to replace the , with . How should I do this? I'd prefer some import method that does this during the import procedure. > > -Janne
From: Rune Allnor on 5 Oct 2006 06:10 Jake the Snake skrev: > Hello, > > I have a huge amount of numbers in a .txt file. The numbers are in the form 2,43252e+1. I need to replace the , with . How should I do this? I'd prefer some import method that does this during the import procedure. > > -Janne If you have one file and the decimal separators are the only commas in the file, load the file into some ascii text editor (notepad, emacs, maube even matlab's editor) and use the "find..replace" function. It will take you 2 seconds to do and the computer may be running for a couple of minutes. Don't spend more of YOUR time (the computer run-time is irrelevant if this truly is a one-off incident) with this than necessary, unless there are other complicating factors or you expect or fear that this number format will occur again. Rune
From: Michael Wild on 5 Oct 2006 08:34 On Thu, 05 Oct 2006 03:10:44 -0700, Rune Allnor wrote: > Jake the Snake skrev: >> Hello, >> >> I have a huge amount of numbers in a .txt file. The numbers are in the form 2,43252e+1. I need to replace the , with . How should I do this? I'd prefer some import method that does this during the import procedure. >> >> -Janne > > If you have one file and the decimal separators are the only commas > in the file, load the file into some ascii text editor (notepad, emacs, > > maube even matlab's editor) and use the "find..replace" function. > > It will take you 2 seconds to do and the computer may be running > for a couple of minutes. Don't spend more of YOUR time (the computer > run-time is irrelevant if this truly is a one-off incident) with this > than > necessary, unless there are other complicating factors or you expect > or fear that this number format will occur again. > > Rune or if you are on linux/unix/mac and this is not a single incident, then you might want to read up on a tool called awk. michael
From: Francis Burton on 5 Oct 2006 15:23
In article <4524edd1$1(a)news1.ethz.ch>, Michael Wild <themiwi.REMOVE.THIS(a)student.ethz.ch> wrote: >or if you are on linux/unix/mac and this is not a single incident, then >you might want to read up on a tool called awk. Or, even simpler, tr(1). If the poster really wants to do it in Matlab, he could try something like: tname = tempname; fidi=fopen(fname, 'r'); fido=fopen(tname, 'w'); while feof(fidi) == 0 line = fgetl(fidi); line = strrep(line, ',', '.'); fprintf(fido, '%s\n', line); end fclose(fidi); fclose(fido); m = dlmread(tname); % or other 'import' of choice delete(tname); Not the most efficient method, but easy to understand. Francis |