fix lines param to csvload
we had lines and skip mixed up
This commit is contained in:
parent
fe47ce12e9
commit
bab3486aca
@ -5,7 +5,7 @@
|
|||||||
- allow \ as an escape character in vips_break_token() [akemrir]
|
- allow \ as an escape character in vips_break_token() [akemrir]
|
||||||
- tiffsave has a "depth" param to set max pyr depth
|
- tiffsave has a "depth" param to set max pyr depth
|
||||||
- libtiff LOGLUV images load and save as libvips XYZ
|
- libtiff LOGLUV images load and save as libvips XYZ
|
||||||
- add gifload_source
|
- add gifload_source, csvload_source, csvsave_target
|
||||||
- revise vipsthumbnail flags
|
- revise vipsthumbnail flags
|
||||||
- add VIPS_LEAK env var
|
- add VIPS_LEAK env var
|
||||||
- add vips_pipe_read_limit_set(), --vips-pipe-read-limit,
|
- add vips_pipe_read_limit_set(), --vips-pipe-read-limit,
|
||||||
|
@ -330,7 +330,6 @@ vips_foreign_load_csv_header( VipsForeignLoad *load )
|
|||||||
int ch;
|
int ch;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
const char *line;
|
|
||||||
|
|
||||||
/* Rewind.
|
/* Rewind.
|
||||||
*/
|
*/
|
||||||
@ -340,7 +339,7 @@ vips_foreign_load_csv_header( VipsForeignLoad *load )
|
|||||||
|
|
||||||
/* Skip the first few lines.
|
/* Skip the first few lines.
|
||||||
*/
|
*/
|
||||||
for( i = 0; i < csv->lines; i++ )
|
for( i = 0; i < csv->skip; i++ )
|
||||||
if( !vips_sbuf_get_line( csv->sbuf ) ) {
|
if( !vips_sbuf_get_line( csv->sbuf ) ) {
|
||||||
vips_error( class->nickname,
|
vips_error( class->nickname,
|
||||||
"%s", _( "unexpected end of file" ) );
|
"%s", _( "unexpected end of file" ) );
|
||||||
@ -349,22 +348,24 @@ vips_foreign_load_csv_header( VipsForeignLoad *load )
|
|||||||
|
|
||||||
/* Parse the first line to get the number of columns.
|
/* Parse the first line to get the number of columns.
|
||||||
*/
|
*/
|
||||||
csv->colno = 0;
|
csv->colno = 1;
|
||||||
csv->lineno = csv->lines;
|
csv->lineno = csv->skip;
|
||||||
do {
|
do {
|
||||||
ch = vips_foreign_load_csv_read_double( csv, &value );
|
ch = vips_foreign_load_csv_read_double( csv, &value );
|
||||||
} while( ch != '\n' &&
|
} while( ch != '\n' &&
|
||||||
ch != EOF );
|
ch != EOF );
|
||||||
width = csv->colno + 1;
|
width = csv->colno;
|
||||||
|
|
||||||
if( !(csv->linebuf = VIPS_ARRAY( NULL, width, double )) )
|
if( !(csv->linebuf = VIPS_ARRAY( NULL, width, double )) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
/* And fetch lines to EOF to get height.
|
/* If @lines is -1, we must scan the whole file to get the height.
|
||||||
*/
|
*/
|
||||||
height = 0;
|
if( csv->lines == -1 )
|
||||||
while( (line = vips_sbuf_get_line( csv->sbuf )) )
|
for( height = 0; vips_sbuf_get_line( csv->sbuf ); height++ )
|
||||||
height += 1;
|
;
|
||||||
|
else
|
||||||
|
height = csv->lines;
|
||||||
|
|
||||||
vips_image_pipelinev( load->out, VIPS_DEMAND_STYLE_THINSTRIP, NULL );
|
vips_image_pipelinev( load->out, VIPS_DEMAND_STYLE_THINSTRIP, NULL );
|
||||||
vips_image_init_fields( load->out,
|
vips_image_init_fields( load->out,
|
||||||
@ -396,7 +397,7 @@ vips_foreign_load_csv_load( VipsForeignLoad *load )
|
|||||||
|
|
||||||
/* Skip the first few lines.
|
/* Skip the first few lines.
|
||||||
*/
|
*/
|
||||||
for( i = 0; i < csv->lines; i++ )
|
for( i = 0; i < csv->skip; i++ )
|
||||||
if( !vips_sbuf_get_line( csv->sbuf ) ) {
|
if( !vips_sbuf_get_line( csv->sbuf ) ) {
|
||||||
vips_error( class->nickname,
|
vips_error( class->nickname,
|
||||||
"%s", _( "unexpected end of file" ) );
|
"%s", _( "unexpected end of file" ) );
|
||||||
@ -409,9 +410,9 @@ vips_foreign_load_csv_load( VipsForeignLoad *load )
|
|||||||
VIPS_FORMAT_DOUBLE,
|
VIPS_FORMAT_DOUBLE,
|
||||||
VIPS_CODING_NONE, VIPS_INTERPRETATION_B_W, 1.0, 1.0 );
|
VIPS_CODING_NONE, VIPS_INTERPRETATION_B_W, 1.0, 1.0 );
|
||||||
|
|
||||||
csv->lineno = csv->lines;
|
csv->lineno = csv->skip;
|
||||||
for( y = 0; y < load->real->Ysize; y++ ) {
|
for( y = 0; y < load->real->Ysize; y++ ) {
|
||||||
csv->colno = 0;
|
csv->colno = 1;
|
||||||
|
|
||||||
for( x = 0; x < load->real->Xsize; x++ ) {
|
for( x = 0; x < load->real->Xsize; x++ ) {
|
||||||
double value;
|
double value;
|
||||||
@ -500,6 +501,7 @@ vips_foreign_load_csv_class_init( VipsForeignLoadCsvClass *class )
|
|||||||
static void
|
static void
|
||||||
vips_foreign_load_csv_init( VipsForeignLoadCsv *csv )
|
vips_foreign_load_csv_init( VipsForeignLoadCsv *csv )
|
||||||
{
|
{
|
||||||
|
csv->lines = -1;
|
||||||
csv->whitespace = g_strdup( " " );
|
csv->whitespace = g_strdup( " " );
|
||||||
csv->separator = g_strdup( ";,\t" );
|
csv->separator = g_strdup( ";,\t" );
|
||||||
}
|
}
|
||||||
@ -659,10 +661,6 @@ vips_foreign_load_csv_source_init( VipsForeignLoadCsvSource *source )
|
|||||||
* You can use a backslash (\) within the quotes to escape special characters,
|
* You can use a backslash (\) within the quotes to escape special characters,
|
||||||
* such as quote marks.
|
* such as quote marks.
|
||||||
*
|
*
|
||||||
* The reader is deliberately rather fussy: it will fail if there are any
|
|
||||||
* short lines, or if the file is too short. It will ignore lines that are
|
|
||||||
* too long.
|
|
||||||
*
|
|
||||||
* @skip sets the number of lines to skip at the start of the file.
|
* @skip sets the number of lines to skip at the start of the file.
|
||||||
* Default zero.
|
* Default zero.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user