Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to import data from Excel. It is located in a single column of the Excel file but each cell contains a comma separated pair of two values as a,b. When I am importing them I have this format {{"a,b"},{"c,d"},...,{"x,y"}, which means just one element not a pair of numbers. How can I have {{a,b},{c,d},...,{x,y}} instead?

share|improve this question
2  
For this specific problem chuy's answer below seems appropriate, but I feel that your actual problem is a botched import in Excel, probably of some kind of CSV file. You probably needed to import that using Excel's import wizard. –  Sjoerd C. de Vries Jun 4 '13 at 19:58

1 Answer 1

up vote 5 down vote accepted

You can use Apply and StringSplit to help out:

rawData = {{"a,b"}, {"c,d"}, {"e,f"}};
Apply[StringSplit[#, ","] &, rawData, {1}]

(*output in InputForm to show structure more clearly*)

{{"a", "b"}, {"c", "d"}, {"e", "f"}}
share|improve this answer
    
many thanks!! if I want in this form of {{a, b`},{c`, d`},...} ,how can I do that?(it is in input form).I mean all just digit. –  Alex Jun 4 '13 at 17:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.