Comment lines CSV / TSV d3

I am trying to read tsv data using d3. However, my data has comment lines as follows

#Comment line @Different comment line xy 1 2 4 2 5 1 

Can d3 be ignored by these lines?

thanks

+4
source share
1 answer

D3 has no built-in way to ignore comment lines. The easiest option is to pre-process the file before parsing with D3:

 d3.text(url, 'text/csv', function(csv) { // remove comment rows with regex - not fully tested, but should work csv = csv.replace(/^[#@][^\r\n]+[\r\n]+/mg, ''); var data = d3.csv.parse(csv); // ... now the rest of your code ... }); 
+5
source

Source: https://habr.com/ru/post/1446715/


All Articles