append to the csv file column-wise under one header

Solution 1:

With pandas, you can use:

import pandas as pd
df = pd.read_csv(file)
df['VERSION'] = 10
df.to_csv(file, index=False)

Solution 2: If there are multiple rows (and you only want first 3), then you can use:

df.loc[df.index < 3, ['VERSION']] = 10   

instead of:

df['VERSION'] = 10

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top