aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/source/apps/cct.rst7
-rw-r--r--src/cct.c24
2 files changed, 27 insertions, 4 deletions
diff --git a/docs/source/apps/cct.rst b/docs/source/apps/cct.rst
index dc2944f2..20aec06c 100644
--- a/docs/source/apps/cct.rst
+++ b/docs/source/apps/cct.rst
@@ -44,6 +44,13 @@ The following control parameters can appear in any order:
Specify a fixed observation height to be used for all input data.
+.. option:: s <n>, --skip-lines=<n>
+
+ .. versionadded:: 5.1.0
+
+ Skip the first *n* lines of input. This applies to any kind of input, wether
+ it comes from ``STDIN``, a file or interactive user input.
+
.. option:: -v, --verbose
Write non-essential, but potentially useful, information to stderr.
diff --git a/src/cct.c b/src/cct.c
index 6b8f35f3..2952f2b7 100644
--- a/src/cct.c
+++ b/src/cct.c
@@ -105,6 +105,7 @@ static const char usage[] = {
" -z value Provide a fixed z value for all input data (e.g. -z 0)\n"
" -t value Provide a fixed t value for all input data (e.g. -t 0)\n"
" -I Do the inverse transformation\n"
+ " -s n Skip n first lines of a infile\n"
" -v Verbose: Provide non-essential informational output.\n"
" Repeat -v for more verbosity (e.g. -vv)\n"
"--------------------------------------------------------------------------------\n"
@@ -116,6 +117,7 @@ static const char usage[] = {
" --time Alias for -t\n"
" --verbose Alias for -v\n"
" --inverse Alias for -I\n"
+ " --skip-lines Alias for -s\n"
" --help Alias for -h\n"
" --version Print version number\n"
"--------------------------------------------------------------------------------\n"
@@ -156,13 +158,19 @@ int main(int argc, char **argv) {
OPTARGS *o;
FILE *fout = stdout;
char *buf;
- int nfields = 4, direction = 1, verbose;
+ int nfields = 4, direction = 1, skip_lines = 0, verbose;
double fixed_z = HUGE_VAL, fixed_time = HUGE_VAL;
int columns_xyzt[] = {1, 2, 3, 4};
const char *longflags[] = {"v=verbose", "h=help", "I=inverse", "version", 0};
- const char *longkeys[] = {"o=output", "c=columns", "z=height", "t=time", 0};
-
- o = opt_parse (argc, argv, "hvI", "cozt", longflags, longkeys);
+ const char *longkeys[] = {
+ "o=output",
+ "c=columns",
+ "z=height",
+ "t=time",
+ "s=skip-lines",
+ 0};
+
+ o = opt_parse (argc, argv, "hvI", "cozts", longflags, longkeys);
if (0==o)
return 0;
@@ -202,6 +210,10 @@ int main(int argc, char **argv) {
nfields--;
}
+ if (opt_given (o, "s")) {
+ skip_lines = atoi (opt_arg(o, "s"));
+ }
+
if (opt_given (o, "c")) {
/* cppcheck-suppress invalidscanf */
int ncols = sscanf (opt_arg (o, "c"), "%d,%d,%d,%d", columns_xyzt, columns_xyzt+1, columns_xyzt+2, columns_xyzt+3);
@@ -265,6 +277,10 @@ int main(int argc, char **argv) {
continue;
}
point = parse_input_line (buf, columns_xyzt, fixed_z, fixed_time);
+ if (skip_lines > 0) {
+ skip_lines--;
+ continue;
+ }
if (HUGE_VAL==point.xyzt.x) {
char *c = column (buf, 1);