# Data is imported as string instead of numbers [closed]

newdata = Import["data.txt", "TSV"];
ListPlot[newdata]


My data.txt file consists of two columns of numbers, separated by commas, like this:

1,4
2,5
3,5


and so on.

When I look at how my newdata output seems to be fine (list of datapoints).

(* in  *) newdata
(* out *) {{1, 4}, {2, 5}, {3, 5}}


But, when I try the ListPlot command, I get just a blank graph at the origin with x and y's that range from 1. Can somebody help me with this type of graphing? Thanks in advance.

-

## closed as off-topic by bobthechemist, Yves Klett, Silvia, rm -rf♦Jan 16 at 17:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – bobthechemist, Yves Klett, rm -rf
If this question can be reworded to fit the rules in the help center, please edit the question.

Does your newdata list look like {{1, 4}, {2, 5}, {3, 5}...}? –  rasher Jan 16 at 5:28
Sorry, cannot upload the data.txt. –  Lance Park Jan 16 at 6:27
Rasher, yes, my newdata looks like that. However, there is no space after the comma in between sets, so instead it looks more like {{1,4}, {2,5}, {3,5}...}. –  Lance Park Jan 16 at 6:28
Please, provide at leas a minimum working example. –  Sektor Jan 16 at 7:01
Are you sure that the newdata is actually numeric? Try FullForm[newdata] and paste the output as an edit to this question. I suspect that you have strings, not pairs of numbers. i.e. {{"1,4"},... not {{1, 4},...}. –  Verbeia Jan 16 at 10:22
show 1 more comment

## 1 Answer

I suspect your data are not numeric, and that the FullForm will actually be strings, like this:

List[List["1,4"],List["2,5"]...]


The reason is probably because you want "CSV" (comma-separated values) not "TSV", which is tab-separated values, in the Import statement.

You might still need to Map ToExpression onto the resulting table (at level 2, check the documentation), but check the FullForm of what you have imported first before assuming you need to do this.

-
add comment