I have some code which takes a text file and calculates the index weight of each row and counts the number of duplicates. I would like to get the results into a dataset I can bind to a table component, but am not sure how to make the conversion.
[code]path = system.file.openFile(“txt”)
if path != None:
contents = system.file.readFileAsString(path).splitlines()
l=[]
for line in contents:
v0 = (len(line[0:20]) - len(line[0:20].lstrip()))/2
v1 = line[0:30].replace("*","").strip()
v2 = contents.count(line[0:30])
v3 = ‘’
l.extend([v0,v1,v2, v3])
for each in l:
print each[/code]
Output:
[code]0
O “Alternate Hierarchies”
1
1
“WC BOM”
1
2
“A2160”
1
3
“etn110444”
1
4
“03m7185”
2
4
“03m7185”
2
4
“14m7396”
2
4
“14m7396”
2
[/code]