MathGroup Archive 1998

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

Search the Archive

Re: Importing CSV (comma separated values) files?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13798] Re: [mg13765] Importing CSV (comma separated values) files?
  • From: "Sherman.Reed" <sherman.reed at worldnet.att.net>
  • Date: Fri, 28 Aug 1998 04:18:21 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Joe,
I have done the following, very successfully, for  about ten years:

1. save the file in csv format:
2. read the file with a text editor and delete all the commas
	(in unix I use vi, in dos I use edit, or ?) 3. then I read the file
into Mathematica.

Sherman C. Reed
sherman.reed at worldnet.att.net

----------
> From: Joe Gwinn <gwinn at ma.ultranet.com>
To: mathgroup at smc.vnet.net
> To: mathgroup at smc.vnet.net
> Subject: [mg13798] [mg13765] Importing CSV (comma separated values) files?
> Date: Monday, August 24, 1998 4:07 AM
> 
> I have been trying to convince Mathematica 3.0.1 to ReadList an ordinary
> CSV spreadsheet file, without luck.  It finds the file OK, then
> complains of an unspecified "syntax error" while reading a number.  No
> useful information is presented; all one knows is that it failed.
> 
> The file contains 240 lines, each line containing 240 non-negative
> integer values separated by commas.  There are no decimal points or
> plus/minus signs.  The values range fom 0 to 255.  For the record, this
> is an output file from a CCD instrumentation TV camera used to measure
> fiber optic nearfield flux distributions.
> 
> I have played with various combinations of RecordLists, WordSeparators,
> and Number, to no avail.
> 
> Even though 240x240= 57,600 entries, Mathematica was not out of memory. 
> The kernel has 25 MB, and the Front End has 10 MB, and the two
> memory-use thermometers were less than 25% full.  If I take the same
> file and edit it into Mathematica nested-list format and turn it into a
> Mathematica notebook, Mathematica handles the data quite well, so the
> problem is purely with the import function.
> 
> 
> The actual output follows:
> 
> raw2Ddata = 
>   ReadList[fullpath,Number,RecordLists->True (*,
> WordSeparators->{","}*)]; Read::"readn": 
>     "Syntax error reading a real number from \!\(\"FWB 4 GB:Gigabit \
> Ethernet:Of\" \\[Ellipsis] \"urs:2D Image Data:50M_OFL.IMG\"\)."
> 
> All I can guess is that Mathematica expects numbers with decimals, and
> isn't getting the decimals.  If that's true, it's a problem, because
> the instruments don't do decimal numbers.   Is there an "Integer"
> declaration for ReadLists?  "Integer" didn't work.
> 
> 
> Anyway, has anybody managed to get this to work, or have any
> suggestions?
> 
> 
> Also, a comment for Wolfram:  Mathematica should be able to read and
> write Microsoft Excel "text" format, and also CSV formatted files
> directly and efficiently, using built-in functions, to enable access to
> the vast range of scientific instruments and analysis packages, and
> databases.  The present manual process is very slow and clumsy.
> 
> 
> And, the error message needs some work.  One easy and very helpful trick
> is to echo the offending line, and then put a line of ^^^ symbols under
> the offending token:
> 
> Now is the t1me for ...
> ___________^^^^_________
> Number found where only letters were expected.
> 
> 
> Joe Gwinn


  • Prev by Date: Mathematica
  • Next by Date: FresnelS & FresnelC
  • Previous by thread: Re: Importing CSV (comma separated values) files?
  • Next by thread: Re: Importing CSV (comma separated values) files?