Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ng-csv to create a tsv file

Ultimately I need to create a TSV file.

I've been using AngularJS v1.2.20 with the ng-csv module. So far ng-csv is great for csv but it doesnt seem to work well with creating tab separation.

My directive looks like

<a ng-csv='getCSVData()' filename='tsv_data_table.tsv' csv-header='headerNames' field-separator="\t">TSV</a>

but it ends up just putting the raw \t between each of the cells as if I wanted to use "\\t" for example

Bob's Tires\t2484775951\t1\t1\t100\t0\t1\t100\t73\t1

I've tried putting \t in decimal-separator and text-delimiter and it didn't help.

like image 295
Brian Schermerhorn Avatar asked Nov 01 '22 06:11

Brian Schermerhorn


2 Answers

Have you tried putting in \t as an HTML entity? That is, as &#09;? Not sure but it might help.

like image 200
jasonhansel Avatar answered Nov 12 '22 19:11

jasonhansel


When Angular was reading the field-separator="\t" it was actually escaping the \ before it passed it to the directive. I made a pull request that got merged into ng-csv that fixed this problem.

So the answer is - it works now to just use field-separator="\t"

like image 21
Brian Schermerhorn Avatar answered Nov 12 '22 18:11

Brian Schermerhorn