How to use the d3-dsv.tsvFormatRows function in d3-dsv

To help you get started, we’ve selected a few d3-dsv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / d3-dsv / d3-dsv-tests.ts View on Github external
});

date = parseRowsMappedArray[0].year;
str = parseRowsMappedArray[0].make;
str = parseRowsMappedArray[0].model;
num = parseRowsMappedArray[0].length;

// tsvFormat(...) ============================================================================

str = d3Dsv.tsvFormat(parseRowsMappedArray);
str = d3Dsv.tsvFormat(parseRowsMappedArray, columns);

// tsvFormatRows(...) ========================================================================

str = d3Dsv.tsvFormatRows(parseRowsMappedArray.map((d, i) => [
    d.year.getFullYear().toString(),
    d.make,
    d.model,
    d.length.toString()
]));

// ------------------------------------------------------------------------------------------
// Test DSV Generalized Parsers and Formatters
// ------------------------------------------------------------------------------------------

// Create custom-delimited Parser/Formatter =================================================

let dsv: d3Dsv.DSV;
dsv = d3Dsv.dsvFormat('|');

// parse(...) ============================================================================
github palerdot / exceljson / js / app.js View on Github external
// now we need to find which module to use for the conversion
                    var parsed = "",
                        parse_error = false,
                        parse_error_msg = "";

                    if (this.isColumnHeader) {
                        try {
                            parsed = tsvFormat( this.getJSON() );
                            parse_error = false;    
                        } catch (e) {
                            parse_error = true;
                            parse_error_msg = "TSV conversion Failed. Please check if JSON is array of objects.";
                        }
                    } else {
                        try {
                            parsed = tsvFormatRows( this.getJSON() );    
                            parse_error = false;    
                        } catch (e) {
                            parse_error = true;
                            parse_error_msg = "TSV conversion Failed. Please check if JSON is array of arrays.";
                        }
                    }

                    if (parse_error) {
                        // show the error message
                        Materialize.toast( parse_error_msg, 4000 );
                        // do not proceed
                        return;
                    }

                    console.log("All success! proceed to download");
                    this.downloadFile( parsed, "tsv" );
github alibaba / kiwi / kiwi-cli / src / export.ts View on Github external
langs.map(lang => {
    const unTranslateMessages = getLangUnTranslate(lang);
    if (unTranslateMessages.length === 0) {
      console.log(`${lang} 该语言文件以及全部被翻译`);
    }
    const content = tsvFormatRows(unTranslateMessages);
    fs.writeFileSync(`./export-${lang}`, content);
    console.log(`${lang} 该语言导出 ${unTranslateMessages.length} 未翻译文案.`);
  });
}