CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

Importing XYZ data from .csv file.

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 8, 2010, 11:21
Default Importing XYZ data from .csv file.
  #1
New Member
 
Edmund Leung
Join Date: Dec 2010
Posts: 2
Rep Power: 0
mtledmund is on a distinguished road
Hello everyone,

I have a .csv file in the following format:
400,5000,600
500,6000,400
400,5000,990

All the variables are separated with a comma.

I want to open the csv file with perl and then create points with all the x y z from that file. So far, I have done the following:

! $data_file = "myfile.csv"; # Defining the data file name.
! open my $HANDLE, $data_file; # Opening the data file
#! @pts_data = (<HANDLE>); # Storing all the data in an array "pts_data"

! foreach (<my $HANDLE>)
! {

! my @file_line = split(/\t/,$_);
! $x_coor = $file_line[0];
! $y_coor = $file_line[1];
! $z_coor = $file_line[2];

#! ($x_coor, $y_coor, $z_coor) = split (/\,/,$_); # Set coordinates from file, xyz splitted by a comma (,).

# Then I create the point, I skipped the section for the post.

!}
!close ($HANDLE)
Can someone please tell me what's wrong with it? Thanks.
Edmund
mtledmund is offline   Reply With Quote

Old   December 9, 2010, 20:17
Default
  #2
Member
 
Ali Torbaty
Join Date: Jul 2009
Location: Sydney, Australia
Posts: 72
Rep Power: 16
AliTr is on a distinguished road
#Check this one


! open(NAMES,"C:/Java/Points.csv") || die "Can't open file $!\n";

! $PointNum=-1;

! while(<NAMES>){
! ( $Xp, $Yp, $Zp )= split(',', $_, 3);
! $PointNum++;
! Create_Point();
! }

! close NAMES;


! sub Create_Point{


! $PointName = "P " . $PointNum;


POINT: $PointName
Apply Instancing Transform = On
Colour = 1, 0, 0
Colour Map = Default Colour Map
Colour Mode = Constant
Colour Scale = Linear
Colour Variable = Pressure
Colour Variable Boundary Values = Hybrid
Culling Mode = No Culling
Domain List = /DOMAIN GROUP:All Domains
Draw Faces = On
Draw Lines = Off
Instancing Transform = /DEFAULT INSTANCE TRANSFORMefault Transform
Lighting = On
Line Width = 2
Max = 0.0 [Pa]
Min = 0.0 [Pa]
Node Number = 1
Option = XYZ
Point = $Xp, $Yp, $Zp
Point Symbol = Ball
Range = Global
Specular Lighting = On
Surface Drawing = Smooth Shading
Symbol Size = 1
Transparency = 0.0
Variable = Pressure
Variable Boundary Values = Hybrid
Visibility = On
OBJECT VIEW TRANSFORM:
Apply Reflection = Off
Apply Rotation = Off
Apply Scale = Off
Apply Translation = Off
Principal Axis = Z
Reflection Plane Option = XY Plane
Rotation Angle = 0.0 [degree]
Rotation Axis From = 0 [m], 0 [m], 0 [m]
Rotation Axis To = 0 [m], 0 [m], 0 [m]
Rotation Axis Type = Principal Axis
Scale Vector = 1 , 1 , 1
Translation Vector = 0 [m], 0 [m], 0 [m]
X = 0.0 [m]
Y = 0.0 [m]
Z = 0.0 [m]
END
END

! } #end sub
Attached Files
File Type: txt ImportExternalPoints.txt (1.8 KB, 20 views)

Last edited by AliTr; December 9, 2010 at 21:04.
AliTr is offline   Reply With Quote

Old   December 11, 2010, 09:23
Default
  #3
New Member
 
Edmund Leung
Join Date: Dec 2010
Posts: 2
Rep Power: 0
mtledmund is on a distinguished road
Quote:
Originally Posted by AliTr View Post
#Check this one


! open(NAMES,"C:/Java/Points.csv") || die "Can't open file $!\n";

! $PointNum=-1;

! while(<NAMES>){
! ( $Xp, $Yp, $Zp )= split(',', $_, 3);
! $PointNum++;
! Create_Point();
! }

! close NAMES;


! sub Create_Point{


! $PointName = "P " . $PointNum;


POINT: $PointName
Apply Instancing Transform = On
Colour = 1, 0, 0
Colour Map = Default Colour Map
Colour Mode = Constant
Colour Scale = Linear
Colour Variable = Pressure
Colour Variable Boundary Values = Hybrid
Culling Mode = No Culling
Domain List = /DOMAIN GROUP:All Domains
Draw Faces = On
Draw Lines = Off
Instancing Transform = /DEFAULT INSTANCE TRANSFORMefault Transform
Lighting = On
Line Width = 2
Max = 0.0 [Pa]
Min = 0.0 [Pa]
Node Number = 1
Option = XYZ
Point = $Xp, $Yp, $Zp
Point Symbol = Ball
Range = Global
Specular Lighting = On
Surface Drawing = Smooth Shading
Symbol Size = 1
Transparency = 0.0
Variable = Pressure
Variable Boundary Values = Hybrid
Visibility = On
OBJECT VIEW TRANSFORM:
Apply Reflection = Off
Apply Rotation = Off
Apply Scale = Off
Apply Translation = Off
Principal Axis = Z
Reflection Plane Option = XY Plane
Rotation Angle = 0.0 [degree]
Rotation Axis From = 0 [m], 0 [m], 0 [m]
Rotation Axis To = 0 [m], 0 [m], 0 [m]
Rotation Axis Type = Principal Axis
Scale Vector = 1 , 1 , 1
Translation Vector = 0 [m], 0 [m], 0 [m]
X = 0.0 [m]
Y = 0.0 [m]
Z = 0.0 [m]
END
END

! } #end sub
Thank you so much AliTr, I just figured out that I must put the full path of the file. Thanks again!

Cheers,
mtledmund
mtledmund is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract data we want from Techplot to a data file vetnav Main CFD Forum 0 July 28, 2010 20:17
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08
[OpenFOAM] Paraview command not found hardy ParaView 7 September 18, 2008 04:59
Compiling OpenFOAM13 on AMD64 with Redhat Enterprise mbeaudoin OpenFOAM Installation 20 June 17, 2008 06:43
Saving particle (DPM) data to file? Philip FLUENT 2 June 12, 2006 01:41


All times are GMT -4. The time now is 11:58.