Jan-18-2020, 04:44 PM
Hi folks,
I need some direction on how to append a single row from one csv file to end of a list in another csv file.
The following is my code but I'm having trouble with copying only the second row to exclude the header plus it is appending with a skipped row.
with open('Preliminary.csv', 'r') as f1:
original = f1.read()
with open('Primary.csv', 'a') as f2:
f2.write('\n')
f2.write(original)
The problem with it is it's copying and appending the entire file and also placing it a few lines below the last in the destination csv file. I have a header that I want to avoid from copying over and only one row after which is the row that I need to append to the other csv file.
Thanks for any input you may provide.
I need some direction on how to append a single row from one csv file to end of a list in another csv file.
The following is my code but I'm having trouble with copying only the second row to exclude the header plus it is appending with a skipped row.
with open('Preliminary.csv', 'r') as f1:
original = f1.read()
with open('Primary.csv', 'a') as f2:
f2.write('\n')
f2.write(original)
The problem with it is it's copying and appending the entire file and also placing it a few lines below the last in the destination csv file. I have a header that I want to avoid from copying over and only one row after which is the row that I need to append to the other csv file.
Thanks for any input you may provide.