Reputation: 237
I am trying to append 10 , 5, 890, 50, Finish
for the Date,High,Low,Volume,Symbol
at the end of the input.csv
file. It will format the contents of the csv file permanently so I use data.to_csv(url,index=False)
. How would I be able to do that?
import pandas as pd
url= 'input.csv'
data = pd.read_csv(url, low_memory=False)
data.to_csv(url,index=False)
Current output:
Date,High,Low,Volume,Symbol
2021-01-15 00:04:00,39358.98,39273.24,0.4786072902,BTCUSD
2021-01-15 00:03:00,39362.37,39166.19,0.2911817448,BTCUSD
2021-01-15 00:02:00,39187.06,39017.72,6.2488076695,BTCUSD
Expected output:
Date,High,Low,Volume,Symbol
2021-01-15 00:04:00,39358.98,39273.24,0.4786072902,BTCUSD
2021-01-15 00:03:00,39362.37,39166.19,0.2911817448,BTCUSD
2021-01-15 00:02:00,39187.06,39017.72,6.2488076695,BTCUSD
10 , 5, 890, 50, Finish
Upvotes: 1
Views: 37
Reputation: 150735
Try with loc
:
data = pd.read_csv(url, low_memory=False)
data.loc[len(data)] = [10 , 5, 890, 50, 'Finish' ]
data.to_csv(url,index=False)
Upvotes: 1