# Graphing from a file

I have a lot experience with traditional programming languages, but almost none with mathematica. I have data that I've transformed and saved to a file in the format

{x,y,time}

{x,y,time}

...

Where x and y are the data I want on the x and y axis, and "time" is a timestamp where each dataset should be its own line. The only "interesting" part of the data is that they're all incredibly small numbers, so they look like "1.00E-010" along the y-axis and I don't know if this will be a problem.

I've tried to use ReadList and then ArrayReshape, but I honestly don't have a good idea as to what I'm doing. Any help, or just a direction to look in, would be huge.

For the record I can modify the formatting of the file somewhat if it's helpful.

Thanks!

• You want all of the x,y pairs with the same time value to be plotted on a separate plot? – Rohit Namjoshi Dec 8 '18 at 23:04
• I'm hoping to plot the lines on the same graph, with each line being a different time. – Jay Dec 8 '18 at 23:08
• So you want a single plot with all of the x,y pairs that have the same time value assigned a different color or label on the plot? – Rohit Namjoshi Dec 8 '18 at 23:30
• That would be ideal, yes! – Jay Dec 8 '18 at 23:38

Assuming you want a single plot with all of the x,y pairs that have the same time value assigned a different color / label then it would be easier if the format of the data is just CSV, remove the curly braces.

rawData = Import["~/data.csv", "CSV"];
groupedData = MapAt[Most, GroupBy[rawData, Last], {All, All}];
ListLinePlot[Values[groupedData], PlotLegends -> Keys[groupedData]]


May have to be changed depending on the format of time

• It looks like that would work, but I've left it running for over an hour and it's still trying to resolve. The file is about 50,000 lines with 3 columns which doesn't seem excessive for a modern computer. Is there any reason mathematica would hang so hard on this? – Jay Dec 9 '18 at 1:52
• @Jay That seems excessively long. I would abort evaluation and check if the data was imported correctly. Length[groupedData] is the number of distinct time values. Is it what you expect? If not then something is wrong with the grouping. What exactly is the format of the time column? You can also try plotting a small subset of the values and make sure it looks right. ListLinePlot[Take[Values[groupedData], 10], PlotLegends -> Take[Keys[groupedData], 10]] – Rohit Namjoshi Dec 9 '18 at 2:17
• Simply moving the directory to something else and then putting it back fixed the error. I don't know why it was being a problem. Thank you so much for all your help! – Jay Dec 9 '18 at 3:59
• @Jay Great. I would appreciate it if you could upvote and accept the answer. Thanks! – Rohit Namjoshi Dec 9 '18 at 4:53