{"record":{"id":"bc8b60c9b93dbb0c","repo":"Yalantis/uCrop","slug":"load-dlm-invalid-dlm-file-s","errorCode":null,"errorMessage":"load_dlm(): Invalid DLM file '%s'.","messagePattern":"load_dlm\\(\\): Invalid DLM file '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":56739,"sourceCode":"      CImg<charT> delimiter(256), tmp(256); *delimiter = *tmp = 0;\n      unsigned int cdx = 0, dx = 0, dy = 0;\n      int err = 0;\n      double val;\n      assign(256,256,1,1,(T)0);\n      while ((err = std::fscanf(nfile,\"%lf%255[^0-9eEinfa.+-]\",&val,delimiter._data))>0) {\n        if (err>0) (*this)(cdx++,dy) = (T)val;\n        if (cdx>=_width) resize(3*_width/2,_height,1,1,0);\n        char c = 0;\n        if (!cimg_sscanf(delimiter,\"%255[^\\n]%c\",tmp._data,&c) || c=='\\n') {\n          dx = std::max(cdx,dx);\n          if (++dy>=_height) resize(_width,3*_height/2,1,1,0);\n          cdx = 0;\n        }\n      }\n      if (cdx && err==1) { dx = cdx; ++dy; }\n      if (!dx || !dy) {\n        if (!file) cimg::fclose(nfile);\n        throw CImgIOException(_cimg_instance\n                              \"load_dlm(): Invalid DLM file '%s'.\",\n                              cimg_instance,\n                              filename?filename:\"(FILE*)\");\n      }\n      resize(dx,dy,1,1,0);\n      if (!file) cimg::fclose(nfile);\n      return *this;\n    }\n\n    //! Load image from a BMP file.\n    /**\n       \\param filename Filename, as a C-string.\n    **/\n    CImg<T>& load_bmp(const char *const filename) {\n      return _load_bmp(0,filename);\n    }\n\n    //! Load image from a BMP file \\newinstance.","sourceCodeStart":56721,"sourceCodeEnd":56757,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L56721-L56757","documentation":"load_dlm() failed to parse at least one row and one column of numeric values from the delimiter-separated file, so dx or dy ended up 0 and it throws CImgIOException. The file opened but its content is not valid DLM numeric data.","triggerScenarios":"Loading a CSV/DLM file whose rows parse to zero columns (wrong delimiter character passed) or which is empty/contains only non-numeric text so no rows are counted.","commonSituations":"Passing the wrong delimiter string (file is ';'-separated but load called with default), loading an Excel-exported file with BOM/headers, or passing an empty file.","solutions":["Check the file is non-empty and contains rows of parseable numbers.","Pass the correct delimiter character/string matching the file (e.g. \",\" vs \";\" vs \"\\t\").","Strip header rows / BOM before loading, or pre-clean the file.","Open the file with a text editor to confirm format matches DLM expectations."],"exampleFix":"// before\nimg.load_dlm(path, 0); // default delim, file is ';'-separated\n// after\nimg.load_dlm(path, \";\");","handlingStrategy":"validation","validationCode":"bool looksLikeNumericDlm(const char* p, const char* delim){ std::ifstream in(p); std::string line; if(!std::getline(in,line)||line.empty()) return false; return line.find_first_of(\"0123456789.eE+-\")!=std::string::npos; }","typeGuard":null,"tryCatchPattern":"try { img.load_dlm(path, delim); } catch (cimg_library::CImgIOException& e) { /* unparseable or empty DLM data */ }","preventionTips":["Match the delimiter argument to the file's actual separator","Strip header rows and BOMs before loading","Confirm the file is non-empty and numeric"],"tags":["cimg","dlm","csv","file-format"],"backgroundTag":"invalid-file-format","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}