Skip to content

Instantly share code, notes, and snippets.

@tklein23
Last active August 29, 2015 14:03
Show Gist options
  • Save tklein23/fe4fea9f96d91bb773b1 to your computer and use it in GitHub Desktop.
Save tklein23/fe4fea9f96d91bb773b1 to your computer and use it in GitHub Desktop.
Reproducing shogun read-file-bug
while true; do echo "0"; done |head -n 5242882 >test-5242882.csv
head -n 5242881 test-5242882.csv >test-5242881.csv
wc -l test*csv
# 5242881 test-5242881.csv
# 5242882 test-5242882.csv
ls -la test*csv
-rw-rw-r-- 1 tklein tklein 10485762 Jun 29 21:44 test-5242881.csv
-rw-rw-r-- 1 tklein tklein 10485764 Jun 29 21:44 test-5242882.csv
./read-csv-file test-5242881.csv
# cols: 5242881, rows: 1
# 34.24user 0.09system 0:34.39elapsed 99%CPU (0avgtext+0avgdata 67272maxresident)k
./read-csv-file test-5242882.csv
# cols: 5242883, rows: 1
# 34.22user 0.09system 0:34.36elapsed 99%CPU (0avgtext+0avgdata 67272maxresident)k
cat read-svmlight-file.cpp
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2014 Thoralf Klein <thoralf@fischlustig.de>
*/
#include <stdio.h>
#include <stdlib.h>
#include <shogun/base/init.h>
#include <shogun/lib/SGMatrix.h>
#include <shogun/io/CSVFile.h>
using namespace shogun;
int main(int argc, char *argv[])
{
init_shogun_with_defaults();
{
SGMatrix<float64_t> matrix;
CCSVFile* test_file = new CCSVFile(argv[1]);
matrix.load(test_file);
printf("cols: %d, rows: %d\n", matrix.num_cols, matrix.num_rows);
SG_UNREF(test_file);
}
exit_shogun();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment