Project

General

Profile

1
#!/usr/bin/env python
2
# Makes a source map spreadsheet from a CSV header
3

    
4
import csv
5
import os.path
6
import sys
7

    
8
sys.path.append(os.path.dirname(__file__)+"/../lib")
9

    
10
import csvs
11
import opts
12

    
13
def main():
14
    # Usage
15
    env_names = []
16
    def usage_err():
17
        raise SystemExit('Usage: '+opts.env_usage(env_names)+' '+sys.argv[0]
18
            +' <header >src_map')
19
    
20
    # Get config from env vars
21
    datasrc = opts.get_env_var('datasrc', None, env_names)
22
    if datasrc == None: usage_err()
23
    
24
    # Get col names
25
    reader, col_names = csvs.reader_and_header(sys.stdin)
26
    
27
    # Write map spreadsheet
28
    writer = csv.writer(sys.stdout)
29
    writer.writerow([datasrc])
30
    for col_name in col_names:
31
        writer.writerow([col_name])
32

    
33
main()
(38-38/45)