Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Importing tab-delimited data files?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62865] Re: Importing tab-delimited data files?
  • From: "Hans Michel" <hmichel at cox.net>
  • Date: Tue, 6 Dec 2005 23:11:08 -0500 (EST)
  • Reply-to: <hmichel at cox.net>
  • Sender: owner-wri-mathgroup at wolfram.com

This may have posted but
 This is a Tabular separated values with empty fields.

So use

Import["yourfilehere","TSV", ConversionOptions -> {"EmptyField" -> ""} ]

No tab or newline options needed.


"AES" <siegman at stanford.edu> wrote in message 
news:dmh9o2$908$1 at smc.vnet.net...
>I create a text file "filedata" with the following content using a text
> editor, with tabs between each number or string (5 tabs per line), and
> no content -- not even a space, just successive adjacent tabs -- in the
> empty slots.
>
> (The columns should line up if your reader uses monospaced type.)
>
> 11   aaa  22   bbb  33   ccc
>              22   bbb  33   ccc
>                            33   ccc
>
> Opening Mathematica and using  !!filedata  reproduces exactly same thing:
>
> 11   aaa  22   bbb  33   ccc
>              22   bbb  33   ccc
>                            33   ccc
>
> Trying to follow this with
>
>   fileDataAsViewed = !!fildata
>
> or
>
>   fileDataAsViewed = %
>
> doesn't work, however.
>
> Using the Mathematica expression
>
>   Import["datafile", "Table",
>      ConversionOptions->{"TableSeparators"->{{"\r","\n"},{"\t"}}}]
>
> gives:
>
> 11   aaa  22   bbb  33   ccc
> 22   bbb  33   ccc
> 33   ccc
>
> Recreating the text file with a space between the tabs in the empty
> slots and applying the same  Import[ ]  expression, however, gives the
> "right" answer:
>
> 11   aaa  22   bbb  33   ccc
>              22   bbb  33   ccc
>                            33   ccc
>
> I suppose this is not exactly unexpected.  The problem is, the app that
> creates the (much larger) tab-delimited filedata text file I really want
> to load into a Mathematica Table creates numerous blank cells, i.e.
> adjacent and unspaced tabs.  I guess I'll just have to go at it with a
> smart text editor and separate adjacent tabs before trying to load it.
>



  • Prev by Date: Bug in Graphics output of Circle primitive?
  • Next by Date: Questions on Apply function
  • Previous by thread: Re: Importing tab-delimited data files?
  • Next by thread: Re: Re: FW: 3D plot question