@@ -296,9 +296,8 @@ public static Table detectedColumnTypes(String csvFileName, boolean header, char
296
296
* @throws IOException
297
297
*/
298
298
public static String printColumnTypes (String csvFileName , boolean header , char delimiter ) throws IOException {
299
- Table t = CsvReader .headerOnly (
300
- CsvReader .detectColumnTypes (csvFileName , header , delimiter ), header , delimiter , csvFileName );
301
- Table structure = t .structure ();
299
+
300
+ Table structure = detectedColumnTypes (csvFileName , header , delimiter );
302
301
303
302
StringBuilder buf = new StringBuilder ();
304
303
@@ -343,6 +342,12 @@ public static String printColumnTypes(String csvFileName, boolean header, char d
343
342
return buf .toString ();
344
343
}
345
344
345
+ /**
346
+ * Retuns the given file after autodetecting the column types, or trying to
347
+ * @param fileName The name of the file to load
348
+ * @return A table containing the data from the file
349
+ * @throws IOException
350
+ */
346
351
public static Table read (String fileName ) throws IOException {
347
352
ColumnType [] columnTypes = detectColumnTypes (fileName , true , ',' );
348
353
return read (columnTypes , true , fileName );
@@ -359,6 +364,15 @@ public static Table read(String fileName, boolean header, char delimiter) throws
359
364
}
360
365
361
366
@ VisibleForTesting
367
+ /**
368
+ * Estimates and returns the type for each column in the delimited text file {@code file}
369
+ *
370
+ * The type is determined by checking a sample of the data in the file. Because only a sample of the data is checked,
371
+ * the types may be incorrect. If that is the case a Parse Exception will be thrown.
372
+ *
373
+ * The method {@code printColumnTypes()} can be used to print a list of the detected columns that can be corrected and
374
+ * used to explicitely specify the correct column types.
375
+ */
362
376
static ColumnType [] detectColumnTypes (String file , boolean header , char delimiter )
363
377
throws IOException {
364
378
0 commit comments