Re: Reading csv with ;
- To: mathgroup at smc.vnet.net
- Subject: [mg99443] Re: Reading csv with ;
- From: Valeri Astanoff <astanoff at gmail.com>
- Date: Wed, 6 May 2009 05:20:35 -0400 (EDT)
- References: <gtp1h5$k58$1@smc.vnet.net>
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.`]]
- Follow-Ups:
- Re: Re: Reading csv with ;
- From: George Woodrow III <georgevw3@mac.com>
- Re: Re: Reading csv with ;