# paraview pvpython error while saving csv data

**URL:** https://discourse.paraview.org/t/paraview-pvpython-error-while-saving-csv-data/16069
**Category:** ParaView Support
**Tags:** python
**Created:** [January 28, 2025, 11:04am UTC](https://discourse.paraview.org/t/paraview-pvpython-error-while-saving-csv-data/16069 "2025-01-28T11:04:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![RaniaYian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/raniayian/32/13936_2.png) [@RaniaYian](https://discourse.paraview.org/u/RaniaYian)
#### Post date: [January 28, 2025, 11:04am UTC](https://discourse.paraview.org/t/paraview-pvpython-error-while-saving-csv-data/16069/1 "2025-01-28T11:04:08Z")

</div>

I am trying to automate my postprocessing and I wrote a script that loads the data, does some clipping and then applies the streamtracer filter. Then I save the result of the streamtracer as a .csv file. When I run the script from the terminal using pvpython, I get this error:

```auto
Traceback (most recent call last):
  File "/data/sponges/Type_C/Lambda1/Re_00500/paraview_streamlines_macro.py", line 198, in <module>
    saveStreamlineCSV(file)
  File "/data/sponges/Type_C/Lambda1/Re_00500/paraview_streamlines_macro.py", line 165, in saveStreamlineCSV
    SaveData('cdv/filename[:4]}.csv', proxy=streamTracer1, ChooseArraysToWrite=1,
  File "/opt/ParaView-5.13.2-MPI-Linux-Python3.10-x86_64/lib/python3.10/site-packages/paraview/simple.py", line 1799, in SaveData
    writer = CreateWriter(filename, proxy, **extraArgs)
  File "/opt/ParaView-5.13.2-MPI-Linux-Python3.10-x86_64/lib/python3.10/site-packages/paraview/simple.py", line 1777, in CreateWriter
    writer_proxy.UnRegister(None)
AttributeError: 'NoneType' object has no attribute 'UnRegister'
error: exception occurred: Segmentation fault

```

I don’t understand if the syntax is wrong or I have to use a entirely different procedure to write the data as a csv.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [January 28, 2025, 11:50am UTC](https://discourse.paraview.org/t/paraview-pvpython-error-while-saving-csv-data/16069/2 "2025-01-28T11:50:31Z")

</div>

Trying a few things with ParaView 5.13.2 locally on my Mac with `SaveData`, I’m not reproducing your error. Could you share the script, at least the full call to `SaveData`? Thanks.

---

<div class="post-metadata">

### Author: ![RaniaYian](https://discourse.paraview.org/user_avatar/discourse.paraview.org/raniayian/32/13936_2.png) [@RaniaYian](https://discourse.paraview.org/u/RaniaYian)
#### Post date: [January 28, 2025, 2:56pm UTC](https://discourse.paraview.org/t/paraview-pvpython-error-while-saving-csv-data/16069/4 "2025-01-28T14:56:04Z")

</div>

```auto
import os
import re
from paraview.simple import *
work_dir = os.getcwd()

def saveStreamlineCSV(filename):
   ResetSession()
   #### disable automatic camera reset on 'Show'
   paraview.simple._DisableFirstRenderCameraReset()
   
   # create a new 'Legacy VTK Reader'
   #tec_3d011404000000vtk = LegacyVTKReader(FileNames=[f"work_dir/{filename}"])
   #### disable automatic camera reset on 'Show'
   #paraview.simple._DisableFirstRenderCameraReset()
   
   # create a new 'Legacy VTK Reader'
   tec_3d014402000000vtk = LegacyVTKReader(registrationName='tec_3d.0144.02000000.vtk', FileNames=['work_dir/{filename}'])
   
   # get active view
   renderView1 = GetActiveViewOrCreate('RenderView')
   
   # show data in view
   tec_3d014402000000vtkDisplay = Show(tec_3d014402000000vtk, renderView1, 'UniformGridRepresentation')
   
   # trace defaults for the display properties.
   tec_3d014402000000vtkDisplay.Representation = 'Outline'
   
   # reset view to fit data
   renderView1.ResetCamera(False, 0.9)
   
   # get the material library
   materialLibrary1 = GetMaterialLibrary()
   
   # update the view to ensure updated data information
   renderView1.Update()
   
   # set scalar coloring
   ColorBy(tec_3d014402000000vtkDisplay, ('POINTS', 'velocity', 'Magnitude'))
   
   # rescale color and/or opacity maps used to include current data range
   tec_3d014402000000vtkDisplay.RescaleTransferFunctionToDataRange(True, False)
   
   # show color bar/color legend
   tec_3d014402000000vtkDisplay.SetScalarBarVisibility(renderView1, True)
   
   # get color transfer function/color map for 'velocity'
   velocityLUT = GetColorTransferFunction('velocity')
   
   # get opacity transfer function/opacity map for 'velocity'
   velocityPWF = GetOpacityTransferFunction('velocity')
   
   # get 2D transfer function for 'velocity'
   velocityTF2D = GetTransferFunction2D('velocity')
   
   # change representation type
   tec_3d014402000000vtkDisplay.SetRepresentationType('Surface')
   
   # create a new 'Clip'
   clip1 = Clip(registrationName='Clip1', Input=tec_3d014402000000vtk)
   
   # toggle interactive widget visibility (only when running from the GUI)
   ShowInteractiveWidgets(proxy=clip1.ClipType)
   
   # Properties modified on clip1
   clip1.ClipType = 'Cylinder'
   clip1.Scalars = ['POINTS', '']
   
   # Properties modified on clip1.ClipType
   clip1.ClipType.Center = [165.0, 200.5, 400.5]
   clip1.ClipType.Axis = [0.0, 0.0, 1.0]
   clip1.ClipType.Radius = 99.0
   
   # show data in view
   clip1Display = Show(clip1, renderView1, 'UnstructuredGridRepresentation')
   
   # trace defaults for the display properties.
   clip1Display.Representation = 'Surface'
   
   # hide data in view
   Hide(tec_3d014402000000vtk, renderView1)
   
   # show color bar/color legend
   clip1Display.SetScalarBarVisibility(renderView1, True)
   
   # update the view to ensure updated data information
   renderView1.Update()
   
   # create a new 'Clip'
   clip2 = Clip(registrationName='Clip2', Input=clip1)
   
   # Properties modified on clip2
   clip2.Scalars = ['POINTS', '']
   
   # Properties modified on clip2.ClipType
   clip2.ClipType.Origin = [165.0, 200.50000000000006, 720.0]
   clip2.ClipType.Normal = [0.0, 0.0, 1.0]
   
   # show data in view
   clip2Display = Show(clip2, renderView1, 'UnstructuredGridRepresentation')
   
   # trace defaults for the display properties.
   clip2Display.Representation = 'Surface'
   
   # hide data in view
   Hide(clip1, renderView1)
   
   # show color bar/color legend
   clip2Display.SetScalarBarVisibility(renderView1, True)
   
   # update the view to ensure updated data information
   renderView1.Update()
   
   # create a new 'Clip'
   clip3 = Clip(registrationName='Clip3', Input=clip2)
   
   # Properties modified on clip3
   clip3.Scalars = ['POINTS', '']
   
   # Properties modified on clip3.ClipType
   clip3.ClipType.Origin = [165.0, 200.50000000000006, 230.0]
   clip3.ClipType.Normal = [0.0, 0.0, -1.0]
   
   # show data in view
   clip3Display = Show(clip3, renderView1, 'UnstructuredGridRepresentation')
   
   # trace defaults for the display properties.
   clip3Display.Representation = 'Surface'
   
   # hide data in view
   Hide(clip2, renderView1)
   
   # show color bar/color legend
   clip3Display.SetScalarBarVisibility(renderView1, True)
   
   # update the view to ensure updated data information
   renderView1.Update()
   
   # create a new 'Stream Tracer'
   streamTracer1 = StreamTracer(registrationName='StreamTracer1', Input=clip3,
       SeedType='Line')
   
   # toggle interactive widget visibility (only when running from the GUI)
   ShowInteractiveWidgets(proxy=streamTracer1.SeedType)
   
   # Properties modified on streamTracer1
   streamTracer1.MaximumStreamlineLength = 10000.0
   streamTracer1.SeedType = 'Point Cloud'
   
   # show data in view
   streamTracer1Display = Show(streamTracer1, renderView1, 'GeometryRepresentation')
   
   # trace defaults for the display properties.
   streamTracer1Display.Representation = 'Surface'
   
   # hide data in view
   Hide(clip3, renderView1)
   
   # show color bar/color legend
   streamTracer1Display.SetScalarBarVisibility(renderView1, True)
   
   # update the view to ensure updated data information
   renderView1.Update()
   
   # save data
   SaveData('cdv/filename[:4]}.csv', proxy=streamTracer1, ChooseArraysToWrite=1,
       PointDataArrays=['IntegrationTime', 'velocity'],
       CellDataArrays=['ReasonForTermination', 'SeedIds'])
   
   # set active source
   SetActiveSource(tec_3d014402000000vtk)
   
   # toggle interactive widget visibility (only when running from the GUI)
   ShowInteractiveWidgets(proxy=tec_3d014402000000vtkDisplay.SliceFunction)
   
   # toggle interactive widget visibility (only when running from the GUI)
   ShowInteractiveWidgets(proxy=tec_3d014402000000vtkDisplay)
   
   # toggle interactive widget visibility (only when running from the GUI)
   HideInteractiveWidgets(proxy=tec_3d014402000000vtkDisplay.SliceFunction)
   
   # toggle interactive widget visibility (only when running from the GUI)
   HideInteractiveWidgets(proxy=tec_3d014402000000vtkDisplay)
   
   # toggle interactive widget visibility (only when running from the GUI)
   HideInteractiveWidgets(proxy=streamTracer1.SeedType)
   

   # save data
   SaveData('{filename[:-4]}.csv', proxy=streamTracer1, PointDataArrays=['AngularVelocity', 'IntegrationTime', 'Normals', 'Rotation', 'Vorticity', 'velocity'],
       CellDataArrays=['ReasonForTermination', 'SeedIds'])

saveEach = 4
data = {}
#os.walk 
for file in os.listdir(work_dir):
    if file.startswith('tec_3d'):
        print(file)
        saveStreamlineCSV(file)
# %%

```

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [July 7, 2025, 10:05am UTC](https://discourse.paraview.org/t/paraview-pvpython-error-while-saving-csv-data/16069/5 "2025-07-07T10:05:32Z")

</div>

> [@RaniaYian](#):
>
> ```auto
> # save data
> SaveData('cdv/filename[:4]}.csv', proxy=streamTracer1, ChooseArraysToWrite=1,
> PointDataArrays=['IntegrationTime', 'velocity'],
> CellDataArrays=['ReasonForTermination', 'SeedIds'])
> 
> ```

The problem starts at this line. I think the file name is missing a `{`, which _may_ be causing a problem with determining which writer to use. That call to `SaveData` seems to work fine on my Mac, however - the file name is just funky.
