MCPcopy Create free account
hub / github.com/OSGeo/gdal / CSVScanFile

Function CSVScanFile

port/cpl_csv.cpp:1147–1183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1145/************************************************************************/
1146
1147static char **CSVScanFile(CSVTable *const psTable, int iKeyField,
1148 const char *pszValue, CSVCompareCriteria eCriteria)
1149{
1150 CSVIngest(psTable->pszFilename);
1151
1152 /* -------------------------------------------------------------------- */
1153 /* Does the current record match the criteria? If so, just */
1154 /* return it again. */
1155 /* -------------------------------------------------------------------- */
1156 if (iKeyField >= 0 && iKeyField < CSLCount(psTable->papszRecFields) &&
1157 CSVCompare(psTable->papszRecFields[iKeyField], pszValue, eCriteria) &&
1158 !psTable->bNonUniqueKey)
1159 {
1160 return psTable->papszRecFields;
1161 }
1162
1163 /* -------------------------------------------------------------------- */
1164 /* Scan the file from the beginning, replacing the ``current */
1165 /* record'' in our structure with the one that is found. */
1166 /* -------------------------------------------------------------------- */
1167 psTable->iLastLine = -1;
1168 CSLDestroy(psTable->papszRecFields);
1169
1170 if (psTable->pszRawData != nullptr)
1171 psTable->papszRecFields =
1172 CSVScanLinesIngested(psTable, iKeyField, pszValue, eCriteria);
1173 else
1174 {
1175 VSIRewindL(psTable->fp);
1176 CPLReadLineL(psTable->fp); /* throw away the header line */
1177
1178 psTable->papszRecFields =
1179 CSVScanLinesL(psTable->fp, iKeyField, pszValue, eCriteria);
1180 }
1181
1182 return psTable->papszRecFields;
1183}
1184
1185char **CSVScanFile(const char *pszFilename, int iKeyField, const char *pszValue,
1186 CSVCompareCriteria eCriteria)

Callers 2

CSVScanFileByNameFunction · 0.85
CSVGetFieldFunction · 0.85

Calls 8

CSVIngestFunction · 0.85
CSLCountFunction · 0.85
CSVCompareFunction · 0.85
CSVScanLinesIngestedFunction · 0.85
VSIRewindLFunction · 0.85
CPLReadLineLFunction · 0.85
CSVScanLinesLFunction · 0.85
CSVAccessFunction · 0.85

Tested by

no test coverage detected