MathGroup Archive 2001

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

Search the Archive

Re: comma delimited files for input?

  • To: mathgroup at
  • Subject: [mg30798] Re: [mg30774] comma delimited files for input?
  • From: Tomas Garza <tgarza01 at>
  • Date: Wed, 19 Sep 2001 00:16:37 -0400 (EDT)
  • References: <>
  • Sender: owner-wri-mathgroup at

Well, you don't have to go as far as Version 5. The problem is solved in
Version 4.1. But, anyway, if you don't want to upgrade, I suggest you read
in your data from Excel using ReadList["file",Word], which will read your
things in ASCII and you'll have them as strings. You may then transform them
into the proper Mathematica expressions using very simple string operations.
Example: suppose you have your data as 23, 67, 1.2, 0.25 in a file called
"example.csv". Then


places the above string under the name "data". I now give a sequence of
operations that will transform this string into a list of numbers {23, 67,
1.2, 0.25}. This will seem absurdly complicated, but you may put everything
together as a function which you may then simply call whenever needed:


(this separates the characters and changes the original commas into stars,
since commas are cumbersome to work with as characters). Now you find the
positions of the stars in the list of characters:


Now you obtain the starting and ending positions of the sequences of
characters which are separated by stars:


Finally, you take all the separate sequences - previously joined together -
and convert them to numbers (Mathematica expressions) which you can work
with normally:


I assure you this looks worse than it actually is, and works very nicely.

Tomas Garza
Mexico City

----- Original Message -----
From: "1.156" <rob at>
To: mathgroup at
Subject: [mg30798] [mg30774] comma delimited files for input?

> I'm using version 4.  In order to get plain ascii decimal numbers into my
program I have to use space delimited data files I'm told in the HELP files.
It works fine but I have to make two versions of all the data files because
others need comma delimited
> files of the same data.
> It sure would be convenient to be able to use comma delimited files (that
import nicely into Excel) for Mathematica work.  Can anyone tell me whether
there is some guru magic that will allow importing csv files or does it boil
down to upgrading to version 5?
> Thanks for any advice on the matter.
> Rob

  • Prev by Date: Re: Math 1 Fonts Problem, Another Aspect
  • Next by Date: RE: Combinations
  • Previous by thread: comma delimited files for input?
  • Next by thread: Re: comma delimited files for input?