@@ -119,6 +119,7 @@ public Table(File file) throws IOException {
119119 */
120120 public Table (File file , String options ) throws IOException {
121121 // uses createInput() to handle .gz (and eventually .bz2) files
122+ init ();
122123 parse (PApplet .createInput (file ),
123124 extensionOptions (true , file .getName (), options ));
124125 }
@@ -146,9 +147,11 @@ public Table(InputStream input) throws IOException {
146147 * @throws IOException
147148 */
148149 public Table (InputStream input , String options ) throws IOException {
150+ init ();
149151 parse (input , options );
150152 }
151153
154+
152155 /**
153156 * @nowebref
154157 */
@@ -210,6 +213,14 @@ public Table(ResultSet rs) {
210213 }
211214
212215
216+ public Table typedParse (InputStream input , String options ) throws IOException {
217+ Table table = new Table ();
218+ table .setColumnTypes (this );
219+ table .parse (input , options );
220+ return table ;
221+ }
222+
223+
213224 protected void init () {
214225 columns = new Object [0 ];
215226 columnTypes = new int [0 ];
@@ -272,7 +283,7 @@ static public String extensionOptions(boolean loading, String filename, String o
272283
273284
274285 protected void parse (InputStream input , String options ) throws IOException {
275- init ();
286+ // init();
276287
277288 boolean awfulCSV = false ;
278289 boolean header = false ;
@@ -302,6 +313,8 @@ protected void parse(InputStream input, String options) throws IOException {
302313 header = true ;
303314 } else if (opt .startsWith (sheetParam )) {
304315 worksheet = opt .substring (sheetParam .length ());
316+ } else if (opt .startsWith ("dictionary=" )) {
317+ // ignore option, this is only handled by PApplet
305318 } else {
306319 throw new IllegalArgumentException ("'" + opt + "' is not a valid option for loading a Table" );
307320 }
@@ -352,24 +365,25 @@ protected void parseBasic(BufferedReader reader,
352365 row ++;
353366 }
354367
355- /*
356- // this is problematic unless we're going to calculate rowCount first
357- if (row % 10000 == 0) {
368+ // this is problematic unless we're going to calculate rowCount first
369+ if ( row % 10000 == 0 ) {
370+ /*
358371 if (row < rowCount) {
359372 int pct = (100 * row) / rowCount;
360373 if (pct != prev) { // also prevents "0%" from showing up
361374 System.out.println(pct + "%");
362375 prev = pct;
363376 }
364377 }
365- try {
366- Thread.sleep(5);
367- } catch (InterruptedException e) {
368- e.printStackTrace();
378+ */
379+ try {
380+ // Sleep this thread so that the GC can catch up
381+ Thread .sleep (10 );
382+ } catch (InterruptedException e ) {
383+ e .printStackTrace ();
384+ }
369385 }
370386 }
371- */
372- }
373387 } catch (Exception e ) {
374388 throw new RuntimeException ("Error reading table on line " + row , e );
375389 }
0 commit comments