(df, output_ply)
| 9 | |
| 10 | # Function to write the DataFrame to a PLY file |
| 11 | def 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 |
| 27 | def convert_csv_to_ply(input_csv, output_ply): |
no outgoing calls
no test coverage detected