RE: Using HiveSQL with Python on Mac

avatar

You are viewing a single comment's thread:

What is export cv?



0
0
0.000
3 comments
avatar

Oh ... typo, sorry, I mean CSV ... to export the data in csv file :)

0
0
0.000
avatar

One of the ways is to use csv module. I just added the following lines of code at the bottom of the script above, and the query results were saved as csv file on my desktop.

import csv
import os

fields = ['delegator', 'delegatee', 'vesting_shares', 'timestamp']
filepath = os.getcwd() + '/Desktop/' + 'delegation.csv'

with open(filepath, 'w') as f:
    write = csv.writer(f)
    write.writerow(fields)
    write.writerows(result)
0
0
0.000
avatar

Great one!
Thanks a lot!

0
0
0.000