Mathematica v8: import a space-delimited table of numbers?
- To: mathgroup at smc.vnet.net
- Subject: [mg115800] Mathematica v8: import a space-delimited table of numbers?
- From: Gordon Robertson <grobertson at bcgsc.ca>
- Date: Fri, 21 Jan 2011 04:30:55 -0500 (EST)
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--