js | 网页上的 json 数据怎么保存到本地表格中?
1.思路
- json 转为 csv 保存到本地
- 或者:json 转为 html 显示到网页中,然后复制到excel中。
(2) 数据
wjl={"code":1,"data":[{"chrmiRNA":"chr1","0":"chr1","startmiRNA":"17018729","1":"17018729","endmiRNA":"17018752","2":"17018752","myIDmiRNA":"human_miRNA_CLIPdb_3383750","3":"human_miRNA_CLIPdb_3383750","sthmiRNA":"0","4":"0","strandmiRNA":"-","5":"-","miRNA":"hsa-miR-2053","6":"hsa-miR-2053","miRNAenergy":"-4.99","7":"-4.99","miRNAscore":"147","8":"147","techmiRNA":"CLIPdb","9":"CLIPdb","chr":"chr1","10":"chr1","start":"17018721","11":"17018721","end":"17018767","12":"17018767","myIDRBP":"Human_RBP_POSTAR2update_49365","13":"Human_RBP_POSTAR2update_49365","sthRBP":"0","14":"0","strandRBP":"-","15":"-","RBP":"UPF1","16":"UPF1","protocol":"HITS-CLIP,CLIPper","17":"HITS-CLIP,CLIPper","tissueType":"HEK_293_FRT","18":"HEK_293_FRT","rawData":"GSE69586,GSM1704215","19":"GSE69586,GSM1704215","score":"9.16564913093e-65","20":"9.16564913093e-65","chrGene":"chr1","21":"chr1","startGene":"17018721","22":"17018721","endGene":"17018883","23":"17018883","geneID":"ENSG00000117118","24":"ENSG00000117118","sthGene":"0","25":"0","strandGene":"-","26":"-","geneType":"protein_coding","27":"protein_coding","genomicContext":"UTR3","28":"UTR3","geneName":"SDHB","29":"SDHB","PhastCons":"0.643239","30":"0.643239","Phylop":"1.00965","31":"1.00965","l1":"chr1:17018729-17018752","32":"chr1:17018729-17018752","l2":"chr1:17018721-17018767","33":"chr1:17018721-17018767"},{"chrmiRNA":"chr1","0":"chr1","startmiRNA":"17018729","1":"17018729","endmiRNA":"17018752","2":"17018752","myIDmiRNA":"human_miRNA_CLIPdb_3383750","3":"human_miRNA_CLIPdb_3383750","sthmiRNA":"0","4":"0","strandmiRNA":"-","5":"-","miRNA":"hsa-miR-2053","6":"hsa-miR-2053","miRNAenergy":"-4.99","7":"-4.99","miRNAscore":"147","8":"147","techmiRNA":"CLIPdb","9":"CLIPdb","chr":"chr1","10":"chr1","start":"17018721","11":"17018721","end":"17018803","12":"17018803","myIDRBP":"human_RBP_CLIPdb_3285450","13":"human_RBP_CLIPdb_3285450","sthRBP":"0","14":"0","strandRBP":"-","15":"-","RBP":"ATXN2","16":"ATXN2","protocol":"PAR-CLIP,PARalyzer","17":"PAR-CLIP,PARalyzer","tissueType":"HEK293T","18":"HEK293T","rawData":"DRA001158,DRS012390","19":"DRA001158,DRS012390","score":"0.9096663971101061","20":"0.9096663971101061","chrGene":"chr1","21":"chr1","startGene":"17018721","22":"17018721","endGene":"17018883","23":"17018883","geneID":"ENSG00000117118","24":"ENSG00000117118","sthGene":"0","25":"0","strandGene":"-","26":"-","geneType":"protein_coding","27":"protein_coding","genomicContext":"UTR3","28":"UTR3","geneName":"SDHB","29":"SDHB","PhastCons":"0.606463","30":"0.606463","Phylop":"1.01427","31":"1.01427","l1":"chr1:17018729-17018752","32":"chr1:17018729-17018752","l2":"chr1:17018721-17018803","33":"chr1:17018721-17018803"},{"chrmiRNA":"chr1","0":"chr1","startmiRNA":"17018729","1":"17018729","endmiRNA":"17018752","2":"17018752","myIDmiRNA":"human_miRNA_CLIPdb_3383750","3":"human_miRNA_CLIPdb_3383750","sthmiRNA":"0","4":"0","strandmiRNA":"-","5":"-","miRNA":"hsa-miR-2053","6":"hsa-miR-2053","miRNAenergy":"-4.99","7":"-4.99","miRNAscore":"147","8":"147","techmiRNA":"CLIPdb","9":"CLIPdb","chr":"chr1","10":"chr1","start":"17018724","11":"17018724","end":"17018765","12":"17018765","myIDRBP":"Human_RBP_POSTAR2update_49366","13":"Human_RBP_POSTAR2update_49366","sthRBP":"0","14":"0","strandRBP":"-","15":"-","RBP":"UPF1","16":"UPF1","protocol":"HITS-CLIP,CLIPper","17":"HITS-CLIP,CLIPper","tissueType":"HEK_293_FRT","18":"HEK_293_FRT","rawData":"GSE69586,GSM1704216","19":"GSE69586,GSM1704216","score":"7.1365700412e-42","20":"7.1365700412e-42","chrGene":"chr1","21":"chr1","startGene":"17018721","22":"17018721","endGene":"17018883","23":"17018883","geneID":"ENSG00000117118","24":"ENSG00000117118","sthGene":"0","25":"0","strandGene":"-","26":"-","geneType":"protein_coding","27":"protein_coding","genomicContext":"UTR3","28":"UTR3","geneName":"SDHB","29":"SDHB","PhastCons":"0.689293","30":"0.689293","Phylop":"1.16863","31":"1.16863","l1":"chr1:17018729-17018752","32":"chr1:17018729-17018752","l2":"chr1:17018724-17018765","33":"chr1:17018724-17018765"}],"message":"success"}
response=wjl.data
2. 代码1
// todo
3. 代码2
//数字的排序:
//response=response.sort(function(x, y){ return x[16].localeCompare(-y[16]) } )
//字符串按照ascii排序:
response=response.sort(function(x, y){ return x[16].localeCompare(y[16]) } )
mirna_binding_exp_content=""
/*
http://111.198.139.65/script/ajax/postar3_crosstalk.php
*/
species="Human"
mirna_binding_exp_content += '<table id="mirna_binding_exp_table" class="table table-striped table-hover">';
mirna_binding_exp_content += '<thead class="thead-light">';
mirna_binding_exp_content += '<tr>';
mirna_binding_exp_content +=
'<th>RBP</th><th>RBP info </th><th>Tissue type</th><th>Position</th><th>Strand</th><th>CLIP-seq technology and peak calling method</th><th>Score<span class="glyphicon glyphicon-question-sign" title="Piranha score: Peak heights from the CLIP-seq data. PARalyzer score: T-to-C transition ratio, while higher ratio means more possible to bind RBPs. MiClip score: Probability of RBP binding. CIMS (CTK) score: Mismatch (HITS-CLIP) / Truncated (iCLIP) peak heights. PureCLIP score: Sum of log posterior probability ratio scores. ENCODE eCLIP score: -log10 P-value. "></span></th><th>PhastCons score</th><th>PhyloP score</th><th>Data accession</th><th>miRNA</th><th>miRNA-binding sites</th><th>Binding energy</th><th>Confidence</th>';
mirna_binding_exp_content += '</tr>';
mirna_binding_exp_content += '</thead>';
mirna_binding_exp_content += '<tbody>';
for (var i = 0; i < response.length; i++) {
mirna_binding_exp_content += '<tr>';
mirna_binding_exp_content +=
'<td class="table-success">' +
response[i][16] +
'</td><td class="table-success">' +
"<a target='_blank' href='./motif.php?RBP=" +
response[i][16] +
'&module=clipdb&species=' +
species +
"'>" +
'info' +
'</a>' +
'</td><td class="table-success">' +
response[i][18] +
'</td>';
mirna_binding_exp_content += '<td class="table-success">' + response[i][33] + '</td>';
mirna_binding_exp_content +=
'<td class="table-success">' +
response[i][26] +
'</td><td class="table-success">' +
response[i][17] +
'</td><td class="table-success">' +
Number(response[i][20]).toFixed(3) +
'</td><td class="table-success">' +
Number(response[i][30]).toFixed(3) +
'</td><td class="table-success">' +
Number(response[i][31]).toFixed(3) +
'</td><td class="table-success">' +
response[i][19] +
'</td><td class="table-danger">' +
response[i][6] +
'</td><td class="table-danger">' +
response[i][32] +
'</a>' +
'</td><td class="table-danger">' +
response[i][7] +
'</td><td class="table-danger">' +
response[i][8] +
'</td>';
mirna_binding_exp_content += '</tr>';
}
mirna_binding_exp_content += '</tbody>';
mirna_binding_exp_content += '</table>';
//输出到新网页
var newWindowObi=window.open('', "_blank");
//console.log(this);
newWindowObi.document.write(mirna_binding_exp_content )
然后就可以把网页上的表格复制到excel中了。
Ref
- http://111.198.139.65/Crosstalk.html