|
[Sponsors] |
April 30, 2008, 16:28 |
Advanced post-processing (to Excel)
|
#1 |
Guest
Posts: n/a
|
Hello,
I'm looking to do some very efficient automatic post-processing but I don't even know if it's feasible so any advice is welcome. What I would like to do is to export data directly from CFX-Post to MS Excel by launching a .cse file and without having to write intermediate files. The thing is I often have to export data from CFX-Post to Excel for post-processing and presentation of CFD results. So far, I used to export results to a .dat file and then copy-paste the raw data in an Excel sheet. However, the number of files I have to deal with is quite important and the whole copy-paste/convert thing is time-consuming (and also very boring). I know that it is possible to write an Excel Macro to read many files but I would then have to specify the File.dat names in my spreadsheet and I would like to avoid that as much as possible (and also get rid of the .dat step). I don't know if this is even possible but I've seen very interesting interaction between Excel and softwares like Pro/Engineer and Catia and it would be amazing to do similar things with CFX. Thanks for your help and time, Felix |
|
May 1, 2008, 05:45 |
Re: Advanced post-processing (to Excel)
|
#2 |
Guest
Posts: n/a
|
You might consider using a high-level interpreted programming language like python (instead of Excel Macro's), it is ideally suited for these kinds of batch processing tasks. See below:
http://www.python.org/ Though you will need to spend some time learning the language it is well worth it in the long run. |
|
May 1, 2008, 09:32 |
Re: Advanced post-processing (to Excel)
|
#3 |
Guest
Posts: n/a
|
You do not need to explicitly state the names of every "DAT" file before importing into Excel.
Hit Alt+F11 to open the VB editor. In the editor go to tools->references. Add the Microsoft Scripting Runtime reference. This makes the "FileSystemObject" available. Put all your dat files in the same folder and run this macro. Be sure to replace "c:\location_of_dat_files" with the correct folder. Sub ImportStuff() Dim fso As New Scripting.FileSystemObject Dim f As Scripting.File Dim w As Worksheet For Each f In fso.GetFolder("c:\location_of_dat_files").Files If LCase(f.Name) Like "*.dat" Then Set w = ActiveWorkbook.Worksheets.Add w.Name = f.Name With w.QueryTables.Add("TEXT;" & f.ShortPath, Range("A1")) .SaveData = True .TextFileParseType = xlDelimited .TextFileCommaDelimiter = True .Refresh False End With End If Next Set w = Nothing Set fso = Nothing End Sub |
|
May 2, 2008, 10:49 |
Re: Advanced post-processing (to Excel)
|
#4 |
Guest
Posts: n/a
|
Thank you very much for your macro Andrew. It does a great part of the long, boring job and it does it fast ! I should be able to adapt it so it fits perfectly in the actual sheet I have. I don't have a lot of experience with Excel macros but I'm sure I can specify where to paste the data instead of creating new sheets.
SpaceDude, Python looks like a great software but it would mean that many people here would have to learn it so I'll stick with simple macros as long as possible. Thanks again, Felix |
|
May 2, 2008, 14:30 |
Re: Advanced post-processing (to Excel)
|
#5 |
Guest
Posts: n/a
|
To change where it outputs the data, look at the code:
Set w = ActiveWorkbook.Worksheets.Add w.Name = f.Name With w.QueryTables.Add("TEXT;" & f.ShortPath, Range("A1")) Instead of creating a new workbook, you can set w to an existing worksheet: Set w = ActiveWorkbook.WorkSheets("NAME_OF_WORKSHEET") You can remove the w.Name line, that just renames the sheet. Then when adding the querytable change the Range("A1") to the appropriate location by putting the origin cell's location within the quotes. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Ansys Post processing | ano999 | ANSYS | 1 | May 27, 2011 17:24 |
NO model vs post processing in coal combustion,CFX | sakalido | CFX | 1 | April 15, 2011 15:07 |
post processing for KIVA | dirga | Main CFD Forum | 5 | April 23, 2009 11:58 |
Tecplot for CFX post processing | pantangi goud | CFX | 2 | August 24, 2005 17:42 |
Post Processing in FEM | Abhijit Tilak | Main CFD Forum | 0 | April 26, 2004 12:59 |