# Use python script to do the repeated work in preview

**URL:** https://discourse.paraview.org/t/use-python-script-to-do-the-repeated-work-in-preview/9786
**Category:** ParaView Support
**Created:** [June 10, 2022, 3:37pm UTC](https://discourse.paraview.org/t/use-python-script-to-do-the-repeated-work-in-preview/9786 "2022-06-10T15:37:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Miraboreasau](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/cc9497/32.png) [@Miraboreasau](https://discourse.paraview.org/u/Miraboreasau)
#### Post date: [June 10, 2022, 3:37pm UTC](https://discourse.paraview.org/t/use-python-script-to-do-the-repeated-work-in-preview/9786/1 "2022-06-10T15:37:19Z")

</div>

Hello, here is the process of how I load and export one data file as .csv

I have some simulation results, like these ouput folders, I need to read the certain one in each output folder such as 6\_Run\_1\_femdem.r2m\_broken\_joint\_100000 (the name should be a variable). Then I open the spreadsheet of it, click the Cell Data (attribute), and Toggle cell connectivity visibility, now I can export the spreadsheet as .csv. Besides this, I also need to export the spreadsheet of the Point Data (attribute)

I will have lots of folders shown in the first pictures, so I think performing the above operation by hand is so hard, can anyone please tell me how to write a script to process them? I believe there are variables in the folder name and read them in a certain order.

I tried to use the trace, but it can only form the script of one data file

Thank you so much!

 ![image](https://discourse.paraview.org/uploads/default/original/2X/3/34454e18c83f272cbf96b71bc4d7e74408aa7ee5.png)

[6\_Run\_1\_femdem.r2m\_broken\_joint\_100000.vtu](https://discourse.paraview.org/uploads/short-url/mZKbdFVI29vgu1ZTXohNnkKJUoy.vtu) (495.6 KB)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [June 13, 2022, 7:59am UTC](https://discourse.paraview.org/t/use-python-script-to-do-the-repeated-work-in-preview/9786/2 "2022-06-13T07:59:23Z")

</div>

Hi @Miraboreasau ,

You can use the “Python Trace” mechanism to generate a script for your usecase.

Best,
