MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ReadList of Complex Numbers

  • To: mathgroup at
  • Subject: [mg21562] Re: ReadList of Complex Numbers
  • From: "Mariusz Jankowski" <mjkcc at>
  • Date: Sat, 15 Jan 2000 02:04:04 -0500 (EST)
  • Organization: University of Southern Maine
  • References: <85mmik$>
  • Sender: owner-wri-mathgroup at

Dear Srikanth,

I assume you have your data organized as two numbers in each row, separated
by white space and/or coma. ReadList makes reading such data very easy and
it will work with versions 3 and 4 of Mathematica.

First read the raw data:

rawdata = ReadList[filename, {Number, Number}]

filename is a string, for example, in Windows it could be
"c:\\temp\\mydata.txt" (note the use of double back-slash). Consult online
Help for the proper method of specifying the path on other platforms.

Next and last, convert the pairs of Real numbers to Complex:

complexdata = Apply[Complex, data, {1}]

Hope this solves your problem.


Mariusz Jankowski
University of Southern Maine
mjkcc at

"Srikanth Raghavan" <srirag at> wrote in message
news:85mmik$26i at
> Hello,
> I have a data file of an array of complex numbers created by a
> Fortran program. I want Mathematica to read this data file as an array
> of complex numbers recognizing each row as a complex number. I have not
> been able to find any way of doing this. Could anyone help? Please reply
> to my e mail address in addition to posting the reply to this newsgroup
> if possible.
> Thanks
> Srikanth
> --------------------------------------------------------------------------
> Srikanth Raghavan
> Rochester Theory Center for
> Optical Science and Engineering
> Dept. of Physics and Astronomy email: srirag at
> University of Rochester
> Rochester, NY 14627
> --------------------------------------------------------------------------

  • Prev by Date: Re: Re[2]: Q: Clear
  • Next by Date: Re: Q: NDSolve
  • Previous by thread: Re: ReadList of Complex Numbers
  • Next by thread: Antwort: "mma" becomes "Mathematica"