Re: Re: Re: Bug in Import?
- To: mathgroup at smc.vnet.net
- Subject: [mg55553] Re: [mg55521] Re: [mg54939] Re: Bug in Import?
- From: "Dale R. Horton" <daleh at wolfram.com>
- Date: Tue, 29 Mar 2005 03:42:35 -0500 (EST)
- References: <cvum3g$bmp$1@smc.vnet.net> <200503030329.WAA21146@smc.vnet.net> <d09c8k$cvk$1@smc.vnet.net> <d0e6pa$osa$1@smc.vnet.net> <200503070710.CAA07704@smc.vnet.net> <200503270743.CAA06265@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Quite simply, it is a bug, which will be fixed in a future version. We
sincerely apologize for any inconvenience.
The bug occurs when a field can be parsed as a sequence of numbers.
There are multiple workarounds, though.
As previously noted,
Import["test.tsv", ConversionOptions -> {"Numeric" -> False}]
will import all fields as strings. You can then post-process to convert
the strings into numbers/dates/etc.
For reasons that are complicated,
Import["test.tsv", "Table", ConversionOptions ->
{"TableSeparators" -> {{"\r", "\n"}, {"\t", "\b"}}}
]
will also work. And the elements will get automatically converted.
-Dale
On Mar 27, 2005, at 1:43 AM, Chris Chiasson wrote:
> Was there ever an explanation for the second line being imported
> differently? WRI?
>
>
> On Mon, 7 Mar 2005 02:10:23 -0500 (EST), Peter Pein <petsie at arcor.de>
> wrote:
>> Hans Michel wrote:
>>
>>> In[1]:= Export["test.tsv", {{"2005-01-24", "2005-02-14"},
>>> {"2005-01-24", \
>>> "2005-02-14"}}]
>>>
>>> Out[1]= test.tsv
>>>
>>> In[2]:= Import["test.tsv", ConversionOptions -> {"Numeric" -> False,
>>> "DateStyle" \
>>> -> "American", "DateSeparator" -> "-"}]
>>>
>>> Out[2]= {{2005-01-24, 2005-02-14}, {2005-01-24, 2005-02-14}}
>>>
>>> In[3]:= Import["test.tsv"]
>>>
>>> Out[3]= {{2005-01-24, 2005-02-14}, {2005, -1, -24, 2005, -2, -14}}
>>>
>>> In[4]:= Import["test.tsv", ConversionOptions -> {"NumberSigns" ->
>>> {"^",
>>> "*"}}]
>>>
>>> Out[4]= {{2005-01-24, 2005-02-14}, {2005-01-24, 2005-02-14}}
>>>
>>> In[5]:= $Version
>>>
>>> Out[5]= 5.1 for Microsoft Windows (October 25, 2004)
>>>
>>> Window XP Profesional
>>>
>>> The format for Import is
>>>
>>> Import["test.tsv", "TSV", Encoding -> None, ConversionOptions ->
>>> {...}]
>>>
>>> That is hard to find in the Help files.
>>>
>>> Still does not explain why the second line gets messed up. Is it the
>>> record
>>> separator, is it the number sign
>>>
>>> Hans
>>>
>>> No problems in Version 5.0
>>> In[1]:=
>>> Export["test.tsv", {{"2005-01-24", "2005-02-14"}, {"2005-01-24", \
>>> "2005-02-14"}}]
>>> Out[1]=
>>> test.tsv
>>> In[2]:=
>>> Import["test.tsv", ConversionOptions -> {"Numeric" -> False,
>>> "DateStyle"
>>> -> "American", "DateSeparator" -> "-"}]
>>> Out[2]=
>>> {{2005-01-24, 2005-02-14}, {2005-01-24, 2005-02-14}}
>>> In[3]:=
>>> Import["test.tsv"]
>>> Out[3]=
>>> {{2005-01-24, 2005-02-14}, {2005-01-24, 2005-02-14}}
>>> In[4]:=
>>> $Version
>>> Out[4]=
>>> 5.0 for Microsoft Windows (June 10, 2003)
>>>
>>>
>>> "DrBob" <drbob at bigfoot.com> wrote in message
>>> news:d09c8k$cvk$1 at smc.vnet.net...
>>>
>>>> Not well indexed? That's putting it mildly.
>>>>
>>>> Here's an example of use (MUCH needed in Help):
>>>>
>>>> Export["test.tsv",
>>>> {{"2005-01-24", "2005-02-14"},
>>>> {"2005-01-24", "2005-02-14"}}]
>>>> Import["test.tsv",
>>>> ConversionOptions -> {"Numeric" ->
>>>> False, "DateStyle" -> "American", "DateSeparator" -> "-"}]
>>>>
>>>> No matter what options are used, however...
>>>>
>>>> Why is the second record converted differently than the first?
>>>>
>>>> Bobby
>>>>
>> [...]
>>>> --
>>>> DrBob at bigfoot.com
>>>> www.eclecticdreams.net
>>>>
>>>
>>>
>> I think, Bobby wanted to say: "If there's a bug, why only in the
>> second
>> line?"
>> It seems a "buggy bug" to me too.
>>
>> --
>> Peter Pein
>> Berlin
>>
>>
>
>
> --
> Chris Chiasson
> Kettering University
> Mechanical Engineering
> Graduate Student
> 1 810 265 3161
>
- References:
- Re: Bug in Import?
- From: "Hans Michel" <hmichel@sdc.cox.net>
- Re: Bug in Import?
- From: Peter Pein <petsie@arcor.de>
- Re: Re: Bug in Import?
- From: Chris Chiasson <chris.chiasson@gmail.com>
- Re: Bug in Import?