# Create a Plot of time versus data from a csv file?

**URL:** <https://community.wolfram.com/t/create-a-plot-of-time-versus-data-from-a-csv-file/9991>\
**Category:** Questions\
**Tags:** data-science, graphics-and-visualization, import-and-export\
**Created:** [February 7, 2017, 11:39pm UTC](https://community.wolfram.com/t/create-a-plot-of-time-versus-data-from-a-csv-file/9991 "2017-02-07T23:39:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sentinelhdx28](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sentinelhdx28](https://community.wolfram.com/u/sentinelhdx28)\
**Post date:** [February 7, 2017, 11:39pm UTC](https://community.wolfram.com/t/create-a-plot-of-time-versus-data-from-a-csv-file/9991/1 "2017-02-07T23:39:54Z")

</div>

I have a csv file I am reading and extracting the second column which indicates time

```
lengthofdataSample=200;
startofdatasample =100;

```

as follows:

```
time=Interpreter["Time"][Take[Import["STsensortrial.csvaa"],{startofdatasample,lengthofdataSample}][[All,2]]];

```

(_and the 13th column which has my acceleration in X direction_)

```
accX=Take[Import["STsensortrial.csvaa"],{startofdatasample,lengthofdataSample}][[All,13]];

```

I simply want to plot acceleration versus time to start with. but I am unable to find appropriate function or syntax to make this work.  
Last thing I tried was:

```
LinePlot[Transpose@{time,accX}]

```

but it only lists the data sets and does not plot.

I also wanted to plot two series, accX data and its moving average on one graph. But I do not see this working either.

```
ListLinePlot[Table[accX,MovingAverage[accX,50]]] 

```

Appreciate help for this newbie to Wolfram.

---

<div class="post-metadata">

**Author:** ![neils](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/neils/32/20595_2.png) [@neils](https://community.wolfram.com/u/neils)\
**Post date:** [February 8, 2017, 7:16am UTC](https://community.wolfram.com/t/create-a-plot-of-time-versus-data-from-a-csv-file/9991/2 "2017-02-08T07:16:15Z")

</div>

If you want to Plot with TimeObjects you need to create a TimeSeries

```
ts = TimeSeries[Transpose[{time, data}]]

```

you may also find that plotting with DateListPlot[ts] will look better on a timeseries.

The other option is to not interpret your times as TimeObjects and plot them as numbers but I do not know the form of the time values in your file so I can’t make any suggestion on how to do this.

Also your code would be simpler if you do something like this (leaving some of your details out):

```
alldata = Import["file","CSV"]
col1 = alldata[[startofdata ;; endofdata, 1]]
col3 = alldata[[startofdata ;; endofdata, 3]]

```

This takes rows starofdata through endofdata and column 1 (or 3)

Regards

---

<div class="post-metadata">

**Author:** ![neils](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/neils/32/20595_2.png) [@neils](https://community.wolfram.com/u/neils)\
**Post date:** [February 8, 2017, 7:20am UTC](https://community.wolfram.com/t/create-a-plot-of-time-versus-data-from-a-csv-file/9991/3 "2017-02-08T07:20:30Z")

</div>

Also as to MovingAverage, Table is the wrong thing – it is for creating lists.

Do

```
ListLinePlot[{col3, MovingAverage[col3, 2]}]

```

You give ListLinePlot a list of data to plot (each one is a separate curve). In this case col3 and its MovingAverage.

---

<div class="post-metadata">

**Author:** ![sentinelhdx28](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sentinelhdx28](https://community.wolfram.com/u/sentinelhdx28)\
**Post date:** [February 8, 2017, 1:56pm UTC](https://community.wolfram.com/t/create-a-plot-of-time-versus-data-from-a-csv-file/9991/4 "2017-02-08T13:56:14Z")

</div>

Thank you, Neil. Very helpful
