I am attempting to implement an Apyori / Association rule. I am struggling to correctly format the dataset for the model to consume. The documentation outlines that model requires
Each item is separated with a tab.
Each transaction is separated with a line feed code. See below or linked documentation
transactions = [ ['beer', 'nuts'], ['beer', 'cheese'], ]
My Tab separated items are coming through fine from the source, but I am struggling to add in a line feed between each transaction/List.
import adodbapi
conn = adodbapi.connect("Provider=MSOLAP.8; \
Data Source='powerbi://api.powerbi.com/v1.0/myorg/MyPowerBIWorskpace'; \
Initial Catalog='MyPowerBIReportNameinService'")
curs = conn.cursor()
dmv = """
EVALUATE SELECTCOLUMNS( 'Table Schema List of Lists','Table Schema List of Lists'[Tables_Clean_Names])
"""
curs.execute(dmv)
results = curs.fetchall()
#Below is the relevant code for the question
testlist =[]
for row in results:
rowlist=[]
a =row[0]
rowlist.append(a)
testlist.append(rowlist)
#apppend a new line leads to additional list item followed by coma
testlist.append('\n')
conn.close()
Using and append (testlist.append('\n')
) leads to an additional comma (see screenshot).
How can I add a newline with the trailing comma?