Revision 1946
Added by Aaron Marcuse-Kubitza almost 13 years ago
bin/map | ||
---|---|---|
52 | 52 |
def usage_err(): |
53 | 53 |
raise SystemExit('Usage: '+opts.env_usage(env_names, True)+' ' |
54 | 54 |
+sys.argv[0]+' [map_path...] [<input] [>output]\n' |
55 |
'Note: Row #s start with 0')
|
|
55 |
'Note: Row #s start with 1')
|
|
56 | 56 |
|
57 | 57 |
## Get config from env vars |
58 | 58 |
|
... | ... | |
64 | 64 |
# never redo in commit mode (manually run `make empty_db` instead) |
65 | 65 |
|
66 | 66 |
# Ranges |
67 |
start = util.cast(int, opts.get_env_var('start', 0, env_names)) # 0-based |
|
67 |
start = util.cast(int, opts.get_env_var('start', 1, env_names)) # 1-based |
|
68 |
# Make start interally 0-based. |
|
69 |
# It's 1-based to the user to match up with the staging table row #s. |
|
70 |
start -= 1 |
|
68 | 71 |
if test: n_default = 1 |
69 | 72 |
else: n_default = None |
70 | 73 |
n = util.cast(int, util.none_if(opts.get_env_var('n', n_default, env_names), |
... | ... | |
301 | 304 |
|
302 | 305 |
def row_ready(row_num, input_row): |
303 | 306 |
def on_error(e): |
304 |
exc.add_msg(e, term.emph('row #:')+' '+str(row_num)) |
|
307 |
exc.add_msg(e, term.emph('row #:')+' '+str(row_num+1)) |
|
308 |
# row # is interally 0-based, but 1-based to the user |
|
305 | 309 |
exc.add_msg(e, term.emph('input row:')+'\n'+str(input_row)) |
306 | 310 |
exc.add_msg(e, term.emph('output row:')+'\n'+str(root)) |
307 | 311 |
ex_tracker.track(e, row_num) |
bin/row | ||
---|---|---|
3 | 3 |
# Warning: Does *not* handle embedded newlines. |
4 | 4 |
|
5 | 5 |
if ! test "$#" -eq 1; then |
6 |
echo "Usage: env [n=...] $0 row_num (zero-based, excluding header) <sheet \
|
|
7 |
>row_out"
|
|
6 |
echo "Usage: env [n=...] $0 row_num <sheet >row_out
|
|
7 |
Note: Row #s start with 1 after the header (which is row 0)"
|
|
8 | 8 |
exit 2 |
9 | 9 |
fi |
10 | 10 |
|
11 | 11 |
test -n "$n" || n=1 |
12 | 12 |
|
13 |
# Add 1 for header row and 1 for tail's 1-based row #s |
|
14 |
tail -n +"$(($1+2))"|head -"$n" |
|
13 |
# Add 1 for header row (tail has 1-based row #s, so don't need to add 1 more) |
|
14 |
tail -n +"$(($1+1))"|head -"$n" |
Also available in: Unified diff
Made row #s 1-based to the user to match up with the staging table row #s