First, thank you both for your time.
Space is an issue, yes, but I agree, I can process them one by one using
some sed scripting. I just thought there is a simple idiom corresponding to
Python's 2-liner above.
In fact, I am wondering, how difficult would it be to make julia accept the
Fortran double precision format natively - is that a big change in Base?
On a separate issue, is there an equivalent to numpy's *loadtxt*?
ps: Tomas, how do you get the nice code-boxes?
On Friday, July 18, 2014 1:01:55 PM UTC+2, Tomas Lycken wrote:
>
> Although you could, probably, do this in pure Julia, is there a reason to
> not write a small preprocessing script using sed (or your OS’s
> equivalent) to create altered *copies* of the data before reading it? If
> HDD space is an issue, you could do this one file at a time using Julia’s
> run method, i.e. something like
>
> dfile = "your-data-file.dat"
> run(`copy_and_replace.sh $dfile`)
> data = readdlm("$dfile.copy")
> run(`rm $dfile.copy`)
>
> where the shell script copy_and_replace.sh copies the raw data (with file
> name given in the first argument) into a new file with the string “.copy”
> appended to the name, and then replaces all occurences of D with E (or e,
> or whatever you need) using sed.
>
> // T
> On Friday, July 18, 2014 12:51:32 PM UTC+2, Andrei Berceanu wrote:
>
> I would prefer to keep my original files intact.
>> In Python I can do
>>
>>
>>
>>
>>
>>
>>
>>
>> *import stringimport numpy as nprule = string.maketrans('D', 'E')data =
>> np.loadtxt(fname, usecols=(2,3),\ converters = {2: lambda
>> val: float(val.translate(rule)),\ 3: lambda
>> val: float(val.translate(rule))})*
>> By the way, is there a Julia equivalent to numpy's *loadtxt*? Because
>> the files are in 3-column format with multiple spaces separating the 3
>> entries on each line and eol chars to separate the lines.
>>
>> On Friday, July 18, 2014 12:33:23 PM UTC+2, Ivar Nesje wrote:
>>>
>>> If you have a reasonable editor, you should be able to open all your
>>> files and issue a global search and replace operation that changes D to E.
>>> If you have many files you can use sed to automate the process.
>>>
>>> kl. 11:41:12 UTC+2 fredag 18. juli 2014 skrev Andrei Berceanu følgende:
>>>>
>>>> Hi all,
>>>>
>>>> I have a lot of datafiles containing numbers in Fortran's double
>>>> precision notation (http://math.hawaii.edu/wordpress/fortran-3/#double),
>>>> i.e. 1.23D-3, instead of the usual E scientific notation.
>>>> Is there a simple way to import the data as Float64?
>>>>
>>>> Tnx!
>>>> Andrei
>>>>
>>>
>