1
$\begingroup$

I am trying to import a comma delimited text file as a Table and I am having two issues:

First, the file imports all of the numbers that should be separate columns as a single string. This is not very useful for actually using the numbers in calculations.

Second, since the numbers are imported as a string, even if I am able to separate them, will I be able to use them in mathematical operations?

Here is a pastebin of the code

$\endgroup$
3
  • $\begingroup$ Why dont you post the code here, format it properly and make a self contained post ? $\endgroup$
    – Sektor
    May 4, 2015 at 8:46
  • $\begingroup$ You can try importing it as a CSV file using Import["150428a.txt", "CSV"] $\endgroup$
    – kglr
    May 4, 2015 at 9:11
  • 1
    $\begingroup$ There is absolutely no need to put things like "Solved" in the title; if you have been sufficiently helped by an answer, you can upvote (once you have the privilege to do so) and then accept. $\endgroup$ May 4, 2015 at 10:06

1 Answer 1

3
$\begingroup$

Have a look at the documentation for CSV. The first issue you have is that your file extension is .txt so Mma imports it as text file instead of a CSV file. Your second issue is that "Table" is not a supported element for either CSV or TXT so I think it is just being ignored.

Even though your file does not have the .csv file type you can still tell Mma what format it is to get what you want.

a = Import["150428a.txt", {"CSV", "Data"}]

Remember that the documentation is your friend.

$\endgroup$
2
  • $\begingroup$ Thank you very much. I was trying to search for the right documentation but couldn't seem to phrase my question in a way that lead to any useful results. Thanks again, it is working now. $\endgroup$
    – Audioworm
    May 4, 2015 at 9:26
  • $\begingroup$ @Audioworm if an answer solves your problem you should mark it as "accepted" it by clicking the gray check mark (✓) on the left side of the answer. $\endgroup$
    – shrx
    May 4, 2015 at 11:41

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.