Extract data to csv file

I want ta ask some questions:
1- I want to read a vcf file and extract the data and build this tables :

So the rows are the id of variation and the columns are the sample name, and the information is genotype info … How?

2- I want to write it on .csv file.

I think this will do it:

mt = hl.import_vcf(...)
mt = mt.select_entries('GT') # drop other fields
mt = mt.key_rows_by().select('rsid') # you don't want locus/alleles key, only rsid
ht = mt.make_table()
ht.export(...file..., delimiter=',')