# Generate and edit csv-file to reimport and use it with blender

Case: I'm exporting a list of coordinates from vertices (x, y, z-Coordinates) to a csv. file.

import bpy
import os

main_path = os.getcwd()
print("writing to: " + main_path + "\n\n")

outputfile = 'G:\\final\\list_of_Vertices.csv'
with open(outputfile, 'w') as w_file:

for i in bpy.context.active_object.data.vertices:
print(i.co," ")
coords = i.co.x, i.co.y, i.co.z
w_file.write(str(coords)+" \n")


So what I get is a csv file like this:

(-8.9578,-10.9873,6.8372) ...

When I try to use this file again to work with the coordinates blender gives me the error:

ValueError: could not convert string to float: '(-8.960794448852539'...).

My question:

How can I get rid of the braces so that I can use the generated csv file?

Thank you very much :)

• Suggest this is more a python question than blender. write(",".join(map(str, coords)) Aug 7 '17 at 15:53
• I'm voting to close this question as off-topic because it is primarily about python. Aug 7 '17 at 15:55