Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Mathematica v8: import a space-delimited table of numbers?
Posted:
Jan 21, 2011 4:30 AM
|
|
I routinely use Import[] for "CSV" and "TSV" files, but now need to import a space-delimited file in which each line has a string as the first element, and then thousands of (space-delimited) decimal numbers.
After looking at the help documentation, and previous posts on MathGroup, I don't see a simple way to Import while specifying that the separator is a space (in R's read.table, I'd use sep=" ").
I expect that I could read in the file as a table, split lines on spaces, then map ToExpression across the numbers in each row. Have I'd missed something in the documentation?
Thanks for your help.
Gordon -- Gordon Robertson BC Cancer Agency Genome Sciences Centre Vancouver BC Canada 604-707-5800 www.bcgsc.ca
--------------080102060502060908060009 Content-Type: text/html; charset="ISO-8859-1" X-Sun-Content-Length: 1332
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> </head> <body bgcolor="#ffffff" text="#000000"> I routinely use Import[] for "CSV" and "TSV" files, but now need to import a space-delimited file in which each line has a string as the first element, and then thousands of (space-delimited) decimal numbers. <br> <br> After looking at the help documentation, and previous posts on MathGroup, I don't see a simple way to Import while specifying that the separator is a space (in R's read.table, I'd use sep=" "). <br> <br> I expect that I could read in the file as a table, split lines on spaces, then map ToExpression across the numbers in each row. Have I'd missed something in the documentation?<br> <br> Thanks for your help.<br> <br> Gordon<br> <div class="moz-signature">-- <br> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <title></title> Gordon Robertson<br> BC Cancer Agency Genome Sciences Centre<br> Vancouver BC Canada<br> 604-707-5800<br> <a class="moz-txt-link-abbreviated" href="http://www.bcgsc.ca">www.bcgsc.ca</a><br> <br> </div> </body> </html>
--------------080102060502060908060009--
|
|
|
|