You can use the pandas library to achieve what you want

[code]

import pandas as pd

count = {'lt60': {'a': 0, 'b': 0, 'c': 0, 'd': 0},

'ge60le90': {'a': 4, 'b': 0, 'c': 0, 'd': 0},

'gt90': {'a': 0, 'b': 1, 'c': 2, 'd': 1} }

df = pd.DataFrame(count).rename_axis('relation_type').reset_index()

df = df.rename(columns={'ge60le90': 'confidence<90',

'gt90': 'confidence>90',

'lt60': 'confidence<60'})

df.to_csv('out.csv', index=False)

# relation_type confidence<90 confidence>90 confidence<60

# 0 a 4 0 0

# 1 b 0 1 0

# 2 c 0 2 0

# 3 d 0 1 0

[/code]