# Trying to plot two time series from data in external file

I am a newbie into Mathematica and taking a steep learning curve. I have been struggling with this for a couple of days now. Can someone point me in the right direction?

I have time-stamped temperature data from two DS18B20 sensors in an external file generated by a bash script. Looks like this:

2017-07-31T00:53:18 15062 15250

2017-07-31T00:53:30 14875 15062

2017-07-31T00:53:43 14687 14875

2017-07-31T00:53:54 14562 14750

2017-07-31T00:54:06 14437 14625

2017-07-31T00:54:20 14312 14500

2017-07-31T00:54:32 14187 14375

2017-07-31T00:54:44 14062 14250

2017-07-31T00:54:55 13937 14125

Gotten so far as to get Mathematica to import the timestamps thus:

DateListPlot[Import["Desktop/temp.dat", "DateStringFormat" -> {"ISODateTime"}]]


But am not able to go further due to gaps in my understanding about how to specify the {Date/Time, Temp1, Temp2} data format.

Would like to plot the data with the timestamp as the independent variable and the two temperature sensor data values as dependent variables.

## 2 Answers

You need to get rid of the empty lists generated by the blank lines in the data file. It can be as simply as this.

data = Import["~/Desktop/temp.dat"] /. {} -> Nothing
DateListPlot[{data[[All, ;; 2]], data[[All, ;; 3 ;; 2]]}]


• Thanks for the prompt response; it works like a charm! Although I still don't comprehend the mechanics of the above syntax but I will do that homework... Thanks again! Jul 31 '17 at 18:11

Here's a way, assuming that your data is in file temp.txt as formatted in your OP:

raw = Import["temp.txt", "Table"];
skipEmptyLines = DeleteCases[raw, {}];
convertDates = MapAt[DateObject, skipEmptyLines, {All, 1}];
twoSets = {{#1, #2}, {#1, #3}} & @@@ convertDates // Transpose;
DateListPlot@twoSets


• Thanks for the prompt response; works exactly as expected and am so glad to see the graph... although I will need some more time to fully comprehend the syntax... Thanks again... Jul 31 '17 at 18:15