I have two lists:
A = ['Apple', 'Dog']
B = ['Cat', 'OWL', 'PEACOCK']
I want output to a csv as :
A
Apple
Dog
B
Cat
OWL
PEACOCK
How can I output these two lists to a csv. I tried with zip but it's only meant for same sized lists
You can add a blank item to list A, and then export it using pandas. Pandas uses a data structure called a DataFrame, but the columns must be equal length. The output .csv file will not show the blank data cell.
import pandas as pd
A = ['Apple', 'Dog']
B = ['Cat', 'OWL', 'PEACOCK']
df1 = pd.DataFrame({'A':A})
df2 = pd.DataFrame({'B':B})
pd.concat([df1,df2],axis=1).to_csv('myfile.csv', index = False)
xlsxwriter and csv, but pandas is much more versatile for csv/dataframe manipulation.