[Paraview] write csv file

Miguel Aguirre aguirre.utn at gmail.com
Wed May 2 03:35:06 EDT 2018


Hello Andrea,

Maybe a Programmable Filter would be a better way. I use this approach to
create csv files with data comming from slices:


import csv

#Create an empty csv file with headers:
FilePath = "C:/Users/Miguel Angel AGUIRRE/Desktop/DataOutput.csv"
Headers=["X","Y","Z","PRESSURE","VELOCITY"]
with open(FilePath, 'wb') as csvfile:
        filewriter = csv.writer(csvfile, delimiter=',')
        filewriter.writerow(Headers)

# Get array data from input:
X = inputs[0].Points[:,0][0]
Y = inputs[0].Points[:,1][0]
Z = inputs[0].Points[:,2][0]
PRESSURE = inputs[0] .GetPointData().GetArray(" PRESSURE ")
VELOCITY  = inputs[0] .GetPointData().GetArray("  VELOCITY  ")


# Add this data to the file (you can use an interation here if you want to
do add info comming from several slices)
FieldData=[X,Y,Z, PRESSURE, VELOCITY ]
with open(FilePath, 'a') as csvfile:
           filewriter = csv.writer(csvfile,lineterminator='\n')
           filewriter.writerow(FieldData)


I hope this will be useful.

Best regards,

Miguel

On Wed, May 2, 2018 at 8:05 AM, Caffagni, Andrea <
Andrea.Caffagni at ferrari.com> wrote:

> Dear users,
>
> I need to write in a .csv file some PointData from a slice.
>
> I wrote my point values inside a ‘for’ cycle thus I would maintain only
> one .csv file and append each time the new data to this.
>
> For this I have created the following commands in my script:
>
>
>
>
>
>                 # create a new 'Pass Arrays'
>
>                 passArrays1 = PassArrays(Input=calculator7)
>
>                 UpdatePipeline()
>
>
>
>                 # Properties modified on passArrays1
>
>                 passArrays1.PointDataArrays = ['pressure', 'velocity']
>
>                 UpdatePipeline()
>
>
>
>                 # Create a new 'SpreadSheet View'
>
>                 spreadSheetView1 = CreateView('SpreadSheetView')
>
>                 spreadSheetView1.ColumnToSort = ''
>
>                 spreadSheetView1.BlockSize = 1024L
>
>                 # uncomment following to set a specific view size
>
>                 # spreadSheetView1.ViewSize = [400, 400]
>
>
>
>                 # export view
>
>                 ExportView('C:/Users/acaffagni/Desktop/ciao.csv',
> ‘a’,view=spreadSheetView1)
>
>
>
>
>
> Unfortunately, the program stop itself at the ‘Properties modified on
> passArrays1’, without updating the pipeline.
>
> Maybe it exists a more smart way to create this .csv file.
>
>
>
> Thanks a lot for the suggestions,
>
> Andrea
>
>
>
> ____________________________________________________________
> _____________________________________________________
>
>
>
> Questo messaggio è da intendersi esclusivamente ad uso del destinatario e
> può contenere informazioni che sono di natura privilegiata, confidenziale o
> non divulgabile secondo le leggi vigenti. Se il lettore del presente
> messaggio non è il destinatario designato, o il dipendente/agente
> responsabile per la consegna del messaggio al destinatario designato, si
> informa che ogni disseminazione, distribuzione o copiatura di questa
> comunicazione è vietata anche ai sensi della normativa vigente in materia
> di protezione dei dati personali. Se avete ricevuto questo messaggio per
> errore, vi preghiamo di notificarcelo immediatamente a mezzo e-mail di
> risposta e successivamente di procedere alla cancellazione di questa e-mail
> e relativi allegati dal vostro sistema.
>
> ____________________________________________________________
> _____________________________________________________
>
>
>
> This message is intended only for the use of the addressee and may contain
> information that is privileged, confidential and exempt from disclosure
> under applicable law. If the reader of this message is not the intended
> recipient, or the employee or agent responsible for delivering the message
> to the intended recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is prohibited under the
> applicable data protection law. If you have received this e-mail by
> mistake, please notify us immediately by return e-mail and delete this
> e-mail and all attachments from your system.
>
>
>
> ____________________________________________________________
> _____________________________________________________
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/paraview
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/paraview/attachments/20180502/aa8db405/attachment.html>


More information about the ParaView mailing list