MathGroup Archive 2009

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

Search the Archive

Re: Re: Reading csv with ;

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99507] Re: [mg99443] Re: Reading csv with ;
  • From: George Woodrow III <georgevw3 at mac.com>
  • Date: Thu, 7 May 2009 06:32:11 -0400 (EDT)
  • References: <gtp1h5$k58$1@smc.vnet.net> <200905060920.FAA01417@smc.vnet.net>

Look at the documentation page for Table (ref/format/Table).

There is a description for an option, "FieldSeparators" , that will  
work. The example uses spaces and '|' as separators, but you could  
specify the semi-colon and it will work.

In earlier versions of Mathematica, this option was not quite as  
buried as it is now.

george



On May 6, 2009, at 5:20 AM, Valeri Astanoff wrote:

> On 5 mai, 11:39, Dennis <detebe... at hotmail.com> wrote:
>> I'm trying to read a csv with mathematica=85
>>
>> Now the problem is that my system settings are at ";" as seperator  
>> instead of more traditional ",". So the it effectively looks like  
>> 1;1;1;1 instead of 1,1,1,1
>>
>> Normally this makes not difference as in most software you can  
>> choose the delimiter/seperator before reading a file, so you pick  
>> =93separator = ; or whatever.
>>
>> With mathematica however I have so far been unable to do this. Now  
>> the question of course: how so I change the seperator with  
>> mathematica?
>>
>> Because quite a few files have a =93;=94 separator I would like to  
>> find a solution within mathematica instead of changing the system  
>> settings.
>>
>> Cheers,
>>
>> Dennis
>
> Good day,
>
> My DIY way to do it:
>
> In[1]:= test=Import["test.csv"]
> Out[1]= {{1.0;2.0;3.0;4.0},{5.0;6.0;7.0;8.0},{9.0;10.0;11.0;12.0}}
>
> In[2]:= %//FullForm
> Out[2]//FullForm= List[List["1.0;2.0;3.0;4.0"],List
> ["5.0;6.0;7.0;8.0"],List["9.0;10.0;11.0;12.0"]]
>
> In[3]:=  test/.str_String:>
> Sequence@@ToExpression@("{"<>StringReplace[str,";"->","]<>"}")
> Out[3]= {{1.,2.,3.,4.},{5.,6.,7.,8.},{9.,10.,11.,12.}}
>
> In[4]:= %//FullForm
> Out[4]//FullForm= List[List[1.`,2.`,3.`,4.`],List[5.`,6.`,7.`, 
> 8.`],List
> [9.`,10.`,11.`,12.`]]
>
>



  • Prev by Date: Re: Picking Off Lists That Have No Numbers
  • Next by Date: Re: Picking Off Lists That Have No Numbers
  • Previous by thread: Re: Reading csv with ;
  • Next by thread: Re: Reading csv with ;