# update automatic data input

**URL:** https://discourse.paraview.org/t/update-automatic-data-input/3222
**Category:** ParaView Support
**Tags:** vtk
**Created:** [December 22, 2019, 6:05am UTC](https://discourse.paraview.org/t/update-automatic-data-input/3222 "2019-12-22T06:05:12Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Vaya\_Putra](https://discourse.paraview.org/user_avatar/discourse.paraview.org/vaya_putra/32/1729_2.png) [@Vaya\_Putra](https://discourse.paraview.org/u/Vaya_Putra)
#### Post date: [December 22, 2019, 6:05am UTC](https://discourse.paraview.org/t/update-automatic-data-input/3222/1 "2019-12-22T06:05:12Z")

</div>

Dear all

my input data is VTU, and to visualize, i need to reload my input file every minute.  
is there any menu in paraview how to update automatically. so i dont need to refresh.

thank you for your help.

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [December 23, 2019, 9:49am UTC](https://discourse.paraview.org/t/update-automatic-data-input/3222/2 "2019-12-23T09:49:21Z")

</div>

There is no option in menu to do that. You will need a `Live Programmable Source`.

in the `Script’ part, put vtkPython code to read your file

```python
from paraview.vtk.vtkIOXML import vtkXMLUnstructuredGridReader as vtuReader
# adapt here to use the appropriate reader
reader = vtuReader()
reader.SetFileName('/path/to/file.vtu')
reader.Update()

self.GetOutputDataObject(0).ShallowCopy(reader.GetOutput())

```

in the second part, `Script (CheckNeedsUpdate)`, write the conditionnal check you want. The first script will be executed only when `SetNeedsUpdate(True)` is called in this second script.

```python
import time
if not hasattr(self, "_my_time"):
  setattr(self, "_my_time", time.time())

t = time.time()
lastTime = getattr(self, "_my_time")
# adapt here to set the time (in sec) you want to wait between updates
if t - lastTime > 60:
  setattr(self, "_my_time", t)
  self.SetNeedsUpdate(True)

```

---

<div class="post-metadata">

### Author: ![Vaya\_Putra](https://discourse.paraview.org/user_avatar/discourse.paraview.org/vaya_putra/32/1729_2.png) [@Vaya\_Putra](https://discourse.paraview.org/u/Vaya_Putra)
#### Post date: [December 23, 2019, 3:46pm UTC](https://discourse.paraview.org/t/update-automatic-data-input/3222/3 "2019-12-23T15:46:36Z")

</div>

thank for your help.

---

<div class="post-metadata">

### Author: ![MiguelAngelAGUIRRE](https://discourse.paraview.org/user_avatar/discourse.paraview.org/miguelangelaguirre/32/2986_2.png) [@MiguelAngelAGUIRRE](https://discourse.paraview.org/u/MiguelAngelAGUIRRE)
#### Post date: [January 22, 2021, 5:19pm UTC](https://discourse.paraview.org/t/update-automatic-data-input/3222/4 "2021-01-22T17:19:47Z")

</div>

Hello,

Thank you very much for this valuable information!. Just for completeness, i let here the corresponding XML code to create a plugin suited for the Live Programmable Source code that you provided.

Regards

Miguel

```
		<StringVectorProperty 
			name="Script" 
			command="SetScript"
			number_of_elements="1"
			default_values="execfile('Path_to_the_SCRIPT_python_file')">
		</StringVectorProperty>
		
		<StringVectorProperty
			name="CheckNeedsUpdateScript"
			label="CheckNeedsUpdateScript"
			command="SetCheckNeedsUpdateScript"
			number_of_elements="1"
			default_values="execfile('Path_to_the_CheckNeedsUpdate_python_script')"
			panel_visibility="advanced">
		</StringVectorProperty>
		
		<Property name="PauseLiveSource" panel_widget="pause_livesource">
			<Documentation>
			  Pause live source.
			</Documentation>
		</Property>
		
		<Hints>
			<LiveSource />
		</Hints>
		
	</SourceProxy>
</ProxyGroup>

```

---

<div class="post-metadata">

### Author: ![anthomas](https://discourse.paraview.org/user_avatar/discourse.paraview.org/anthomas/32/7342_2.png) [@anthomas](https://discourse.paraview.org/u/anthomas)
#### Post date: [July 19, 2021, 8:08pm UTC](https://discourse.paraview.org/t/update-automatic-data-input/3222/5 "2021-07-19T20:08:25Z")

</div>

How does one prevent this from creating a new reader every time the script is called? I am using an OpenFOAMReader and the script creates a new one each time instead of updating the original one.

---

<div class="post-metadata">

### Author: ![bigfooted](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bigfooted/32/6347_2.png) [@bigfooted](https://discourse.paraview.org/u/bigfooted)
#### Post date: [January 8, 2023, 6:49pm UTC](https://discourse.paraview.org/t/update-automatic-data-input/3222/6 "2023-01-08T18:49:33Z")

</div>

@nicolas.vuaille This works great! But is there a way to get this to work for a csv file? I would like to visualize a real time line chart of a csv file.  
I can use CSVReader to read the csv file, but I don’t know how to match the output with the available output data type.

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [January 9, 2023, 9:51am UTC](https://discourse.paraview.org/t/update-automatic-data-input/3222/7 "2023-01-09T09:51:48Z")

</div>

Hi,

> [@bigfooted](#):
>
> how to match the output

A csv file should output a `vtkTable`.

> [@anthomas](#):
>
> How does one prevent this from creating a new reader

Be careful, in this script you should create a `VTK` reader not, a ParaView reader proxy.

---

<div class="post-metadata">

### Author: ![bigfooted](https://discourse.paraview.org/user_avatar/discourse.paraview.org/bigfooted/32/6347_2.png) [@bigfooted](https://discourse.paraview.org/u/bigfooted)
#### Post date: [January 11, 2023, 2:46pm UTC](https://discourse.paraview.org/t/update-automatic-data-input/3222/8 "2023-01-11T14:46:54Z")

</div>

That makes sense, thanks! I also forgot to convert to numpy, the final code below works for my csv file:

```auto
import numpy as np
import pandas as pd
data = pd.read_csv("history.csv",sep=',')
for name in data.keys():
  array = data[name].to_numpy()
  output.RowData.append(array,

```
