0
$\begingroup$

Consider a file 'temp.txt' (alternative link). I am trying to import it as a data-file, i.e. in the form

XXX XXX XXX XXX 

where XXX denotes numbers. However, I am not able to do this. Could you please show me how to fix it?

$\endgroup$

1 Answer 1

2
$\begingroup$
Partition[ N@Chop@ToExpression@StringReplace[ "{" <> Import["file_path\temp.txt"] <> "}", {"#" ~~ Shortest[__] ~~ "\n" -> "", "\t" -> ",", "e+" -> "*^", "e-" -> "*^-"} ], 4 ] 

{{0.,0.,0.,0.25},{0.5,0.75,1.,1.25},{1.5,1.75,2.,2.25},{2.5,2.75,3.,3.25},{3.5,3.75,4.,4.25},<<449164>>,{0.,0.,0.,0.},{0.,0.,0.,0.},{0.,0.,0.,0.},{0.,0.,0.,0.},{0.,0.,0.,0.}}

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.