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$
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$

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.