0

I am new to programming and Python and need to write a script so I can output data to Excel. For this purpose I am currently writing to a CSV.

However, I have a requirement to show this data so it is readable and am not sure how to achieve this.

I have a matrix of data

[
 ['FileName', 'File1', 'File2'], 
 ['Count', '1643', '1646'], 
 ['SomeNumbers', ['-15,51,-58,17'], ['-15,51,-58,17']],  
 ['MoreData', ['a', 'b', 'c', 'd' ], ['a', 'b', 'c', 'd']]
]

To print this, I wrote:

for item in matrix:
    writer.writerow(item)

I wrote the results to a CSV and got this:

FileName    FileA   FileB
FeatureType Polygon Polygon
FeatureCount    1643    1646
SomeNumbers ['-15,51,-58,17'], ['-15,51,-58,17']
MoreData    ['a', 'b', 'c', 'd'] ['a', 'b', 'c', 'd']

What I would like to do is to write code such that I get output like this instead:

FileName    FileA   FileB
FeatureType Polygon Polygon
FeatureCount    1643    1646
SomeNumbers     -15     -15
                 51      51
                -58    -58
                 17     17
MoreData    a       a
            b       b
            c       c
            d       d

Thanks for your help.

GeoMeteoMe
  • 161
  • 1
  • 1
  • 9
  • Possible duplicate of [writing string to a file on a new line everytime?](http://stackoverflow.com/questions/2918362/writing-string-to-a-file-on-a-new-line-everytime) – Tony Babarino Mar 01 '16 at 23:08
  • Can you supply the entire code necessary to reproduce the problem, please? Also, please clarify whether you're writing this data to a CSV file, printing it to the console, or both. – Prune Mar 02 '16 at 00:20

0 Answers0