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?

  • 2
    $\begingroup$ 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. $\endgroup$ Jun 4 '13 at 19:58

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"}}
  • $\begingroup$ 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. $\endgroup$
    – Alex
    Jun 4 '13 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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