|
[Sponsors] |
December 8, 2010, 12:21 |
Importing XYZ data from .csv file.
|
#1 |
New Member
Edmund Leung
Join Date: Dec 2010
Posts: 2
Rep Power: 0 |
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 |
|
December 9, 2010, 21:17 |
|
#2 |
Member
Ali Torbaty
Join Date: Jul 2009
Location: Sydney, Australia
Posts: 72
Rep Power: 17 |
#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 Last edited by AliTr; December 9, 2010 at 22:04. |
|
December 11, 2010, 10:23 |
|
#3 | |
New Member
Edmund Leung
Join Date: Dec 2010
Posts: 2
Rep Power: 0 |
Quote:
Cheers, mtledmund |
||
|
|
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 21:17 |
OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 20:08 |
[OpenFOAM] Paraview command not found | hardy | ParaView | 7 | September 18, 2008 05:59 |
Compiling OpenFOAM13 on AMD64 with Redhat Enterprise | mbeaudoin | OpenFOAM Installation | 20 | June 17, 2008 07:43 |
Saving particle (DPM) data to file? | Philip | FLUENT | 2 | June 12, 2006 02:41 |