I am working on some csv files and would like to convert them to txt. I have developed a for loop in Python in which the comma is set as field separator. However, I don't know how to import the columns contained in inverted commas ". Here is the code:
import numpy as np
# a=np.genfromtxt('Nuvole_split\Tri_8851.csv', delimiter=',',skip_header=1)
# np.savetxt('Prova.txt', a)
#Conversione nuvole in txt
for i in range (1,9226):
try:
a=np.genfromtxt(r'Nuvole_split\Tri_%i.csv' %i, delimiter=',',skip_header=1)
export=np.transpose((a[:,0],a[:,1],a[:,2]))
np.savetxt(r'D:\Tesi\VAIA_grosso\Nuvole_split\Conv\Nuvola%i.txt' %i, export)
except Exception as e:
print(e)
And this is a snippet of the csv to be converted: Screenshot
I would also like to import the last column but, for now, it returns an error and fills it with nan