I have a *.txt file with values like so:

0 2 4 3 4 2

the position in this huge *.txt corresponds to the x and y coordinates of the value (in the text file). For example that 0 has coordinates {0, 0}, the 2 has coordinates {0, 1} and so on. After the
{0, 1000} comes the value with {1, 0} coordinates.

I just need to import this file and later on re-use it.


1 Answer 1


Some fake data:

faketxtdata=StringJoin@@Table[ToString[RandomInteger[{0,10}]]<>"  ",{10201}];

The first 20 characters of the data:

(* 9  10  2  4  10  10   *)

The file fakedata.txt contains a single string:


Using "Words" as the second argument of Import, imports

words separated by spaces, given as a list of strings.

imp=Import["fakedata.txt", "Words"];

And ... a possible interpretation of

Plot data from txt


I need to make a density plot

in OP's original post:


enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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