MCPcopy Index your code
hub / github.com/processing/processing / convertBasic

Method convertBasic

core/src/processing/data/Table.java:4741–4812  ·  view source on GitHub ↗
(BufferedReader reader, boolean tsv,
                              File outputFile)

Source from the content-addressed store, hash-verified

4739
4740 // converts a TSV or CSV file to binary.. do not use
4741 protected void convertBasic(BufferedReader reader, boolean tsv,
4742 File outputFile) throws IOException {
4743 FileOutputStream fos = new FileOutputStream(outputFile);
4744 BufferedOutputStream bos = new BufferedOutputStream(fos, 16384);
4745 DataOutputStream output = new DataOutputStream(bos);
4746 output.writeInt(0); // come back for row count
4747 output.writeInt(getColumnCount());
4748 if (columnTitles != null) {
4749 output.writeBoolean(true);
4750 for (String title : columnTitles) {
4751 output.writeUTF(title);
4752 }
4753 } else {
4754 output.writeBoolean(false);
4755 }
4756 for (int type : columnTypes) {
4757 output.writeInt(type);
4758 }
4759
4760 String line = null;
4761 //setRowCount(1);
4762 int prev = -1;
4763 int row = 0;
4764 while ((line = reader.readLine()) != null) {
4765 convertRow(output, tsv ? PApplet.split(line, '\t') : splitLineCSV(line, reader));
4766 row++;
4767
4768 if (row % 10000 == 0) {
4769 if (row < rowCount) {
4770 int pct = (100 * row) / rowCount;
4771 if (pct != prev) {
4772 System.out.println(pct + "%");
4773 prev = pct;
4774 }
4775 }
4776// try {
4777// Thread.sleep(5);
4778// } catch (InterruptedException e) {
4779// e.printStackTrace();
4780// }
4781 }
4782 }
4783 // shorten or lengthen based on what's left
4784// if (row != getRowCount()) {
4785// setRowCount(row);
4786// }
4787
4788 // has to come afterwards, since these tables get built out during the conversion
4789 int col = 0;
4790 for (HashMapBlows hmb : columnCategories) {
4791 if (hmb == null) {
4792 output.writeInt(0);
4793 } else {
4794 hmb.write(output);
4795 hmb.writeln(PApplet.createWriter(new File(columnTitles[col] + ".categories")));
4796// output.writeInt(hmb.size());
4797// for (Map.Entry<String,Integer> e : hmb.entrySet()) {
4798// output.writeUTF(e.getKey());

Callers

nothing calls this directly

Calls 11

getColumnCountMethod · 0.95
convertRowMethod · 0.95
splitMethod · 0.95
splitLineCSVMethod · 0.95
createWriterMethod · 0.95
writeUTFMethod · 0.80
writelnMethod · 0.80
writeMethod · 0.65
printlnMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected