Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Importing data

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113474] Re: Importing data
  • From: James Stein <mathgroup at stein.org>
  • Date: Sat, 30 Oct 2010 04:37:37 -0400 (EDT)

In addition to prior suggestions, you might consider processing the file
before giving it to Mathematica.  From your file description, it seems that
very simple grep rules could insert commas into the correct positions,
transforming your file into csv format. On a Mac, I would use the free
'TextWrangler' to do this. Another approach would be to use a string
processing language (such as Perl) to convert the file.

On Wed, Oct 27, 2010 at 2:18 AM, David Higgins <dhi67540 at bigpond.net.au>wrote:

> Hi all,
>
> Relatively new user here.  I have a text file containing 540,000 lines of
> data in 30 columns, fixed width.  Not all columns are populated for all
> data
> lines.
>
> When I import, Mathematica creates a list and populates the list elements
> from 1 to the number of data elements it finds in each line, ignoring the
> empty columns so for data lines with only, say 20 columns populated, it has
> populated data elements 1 to 20 instead of skipping the missing ones.  Is
> there a way to import data that allows me to define a template for the data
> elements so that the right data ends up in the right elements in the list?
>
> Cheers
>
> David
>
>
>


  • Prev by Date: How to convert Inset graphics to absolute coords?
  • Next by Date: NotebookDirectory[] and UNC paths
  • Previous by thread: Re: Importing data
  • Next by thread: If and Piecewise don't quite do what I need