Read from CSV - Output Table Formatting

Hi All,

I have made a hook that exports out a data into csv, I would want to that CSV to be read inside Revit using output.print_table() as an interface but the formatting is messed up which i don’t know how to troubleshoot. Here’s my code:

output = script.get_output()

file_path = r'xxxxx\doc_open_log.csv'
with open(file_path, 'r') as csvfile:
    data = csvfile.readlines()

output.center()
output.print_table(table_data=data,
                   title='Doc Open',
                   columns=['User', 'Computer', 'Model', 'Date', 'Time'],
                   formats=['', '', '', '', ''])

here’s the output:

if i just print it out without the table it turns out fine, but not on the table.

thanks in advance!

With some of your data, it would be easier to analyze the structure and the issue.

data should look like:

data =
    [
         [ User name, computer,model,date,time], # line 1
         [ User name, computer,model,date,time], # line 2
         [ User name, computer,model,date,time] # line 3
    ]
1 Like

thanks man got it! so it should be list of list

with open(file_path, 'r') as csvfile:
    data = [line.strip().split(',') for line in csvfile]
1 Like