2
$\begingroup$

I have a txt file like this:

A   B C
400 2 3
2   1 8

Now I would like to import the txt file and write it all on one line instead of in columns, so like that:

A B C 400 2 3 2 1 8

How can I achieve this with Mathematica ?

$\endgroup$
0

1 Answer 1

2
$\begingroup$
StringRiffle[ReadList["C:/temp/temp.txt", Word], " "]
$\endgroup$
3
  • $\begingroup$ This is great ! Thanks a lot !! $\endgroup$
    – james
    Aug 15, 2018 at 10:41
  • $\begingroup$ @Alan, if the input txt is: ABC 123 BCD 234 EFG 345,output I need is 123 234 345, how can I do in MMA? $\endgroup$
    – ABCDEMMM
    Nov 1, 2018 at 1:52
  • $\begingroup$ New questions should be created as a new question. Anyway, the Mma documentation for ReadList and Part are excellent; start there. E.g., ReadList[StringToStream@"ABC 123 BCD 234 EFG 345", {Word, Number}][[All,2]]. $\endgroup$
    – Alan
    Nov 1, 2018 at 13:03

Your Answer

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

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