Skip to content

Instantly share code, notes, and snippets.

@beatrizalbiero
Created December 27, 2017 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beatrizalbiero/3a85332abb205e6d187ed43113f06351 to your computer and use it in GitHub Desktop.
Save beatrizalbiero/3a85332abb205e6d187ed43113f06351 to your computer and use it in GitHub Desktop.
copy first column to last colum of a csv file
def readCSV(filename):
f = open(filename,"r")
y = open('saida.csv',"w")
for row in f:
treat = row.strip("\n").strip("\r")+';\n'
new_list = treat.split(';') #str to list
new_list[-1] = new_list[0]
new_string = ''
for i in range(0,len(new_list)-1):
new_string = new_string + new_list[i] + ';'
new_string = new_string + new_list[-1] + '\n'
y.write(new_string)
f.close()
y.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment