MCPcopy Create free account
hub / github.com/TEA-Lab/TwoByTwo / write_ply

Function write_ply

data_util/csv_to_ply.py:11–24  ·  view source on GitHub ↗
(df, output_ply)

Source from the content-addressed store, hash-verified

9
10# Function to write the DataFrame to a PLY file
11def write_ply(df, output_ply):
12 with open(output_ply, 'w+') as ply_file:
13 ply_file.write('ply\n')
14 ply_file.write('format ascii 1.0\n')
15 ply_file.write(f'element vertex {len(df)}\n')
16 ply_file.write('property float x\n')
17 ply_file.write('property float y\n')
18 ply_file.write('property float z\n')
19 ply_file.write('property uchar red\n')
20 ply_file.write('property uchar green\n')
21 ply_file.write('property uchar blue\n')
22 ply_file.write('end_header\n')
23 for _, row in df.iterrows():
24 ply_file.write(f'{row["x"]} {row["y"]} {row["z"]} 255 0 0\n')
25
26# Main function to convert CSV to PLY
27def convert_csv_to_ply(input_csv, output_ply):

Callers 1

convert_csv_to_plyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected