我想要的是一个可以在表中输出数据的函数,如下所示:
作为一个起点,我有以下data table code,它可以从表格的CSV中准确地显示上面的图片:
"variable","aror","asd","maxdd"
"Convertible Arbitrage",0.0770203710991655,0.0694461870173684,-0.292688394529575
"CTA Global",0.0767109922711062,0.0870559916457339,-0.11676813742079
"Distressed Securities",0.0975096216543971,0.0635590261337229,-0.229232535454022
"Emerging Markets",0.0936124939942315,0.133615370977481,-0.359789528051813
要使它使用此功能:
function drawDataTableFromDsv(dataFile, fileDelimiter, suppressedHeaders, outputElementId) {
var dsv = d3.dsv(fileDelimiter, "text/utf-8"); // plain
dsv(dataFile, function(error, data) {
if (error)
return console.error(error);
var dataHeaders = d3.keys(data[0]);
dataHeaders = _.difference(dataHeaders, suppressedHeaders);
console.log(dataHeaders)
data.forEach(function (d, i) {
//2015-05-13T01:21:07
if (d.datePosted.trim() != "")
d.datePosted = isoDateFormat.parse(d.datePosted);
});
tabulate(data, dataHeaders, outputElementId);
});
}
到目前为止一切顺利,但这里的事情变得有趣......
我不太关心这些数据,我关心的是RDF的文件,看起来像这样:
<?xml version="1.0" ?>
<rdf:RDF
xmlns:owl='http://www.w3.org/2002/07/owl#'
xmlns:edsa='http://www.edsa-project.eu/edsa#'
xmlns:pp='ftp://ftp-sop.inria.fr/wimmics/soft/pprint/'
xmlns:kg='http://ns.inria.fr/edelweiss/2010/kgram/'
xmlns:schema='http://schema.org/'
xmlns:geo='http://www.w3.org/2003/01/geo/wgs84_pos#'
xmlns:xml='http://www.w3.org/XML/1998/namespace'
xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#'
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
xmlns:xsd='http://www.w3.org/2001/XMLSchema#'
xmlns:cos='http://www.inria.fr/acacia/corese#'
xmlns:geonames='http://www.geonames.org/ontology#'>
<rdf:Description rdf:about='http://sws.geonames.org/2867714/'>
<geonames:alternateName xml:lang='tl'>Lungsod ng München</geonames:alternateName>
<geonames:alternateName xml:lang='rm'>Minca</geonames:alternateName>
<geonames:alternateName xml:lang='pfl'>Minche</geonames:alternateName>
<geonames:alternateName xml:lang='bar'>Minga</geonames:alternateName>
<geonames:alternateName xml:lang='bs'>Minhen</geonames:alternateName>
<geonames:alternateName xml:lang='hbs'>Minhen</geonames:alternateName>
<geonames:alternateName xml:lang='lv'>Minhene</geonames:alternateName>
<geonames:alternateName xml:lang='lt'>Miunchenas</geonames:alternateName>
<geonames:alternateName xml:lang='cs'>Mnichov</geonames:alternateName>
<geonames:alternateName xml:lang='hsb'>Mnichow</geonames:alternateName>
<geonames:alternateName xml:lang='sk'>Mníchov</geonames:alternateName>
<geonames:alternateName xml:lang='pl'>Monachium</geonames:alternateName>
<geonames:alternateName xml:lang='sc'>Monaco de Baviera</geonames:alternateName>
<geonames:alternateName xml:lang='vec'>Monaco de Baviera</geonames:alternateName>
<geonames:alternateName xml:lang='it'>Monaco di Baviera</geonames:alternateName>
<geonames:alternateName xml:lang='nap'>Monaco e Baviera</geonames:alternateName>
<geonames:alternateName xml:lang='co'>Monacu di Baviera</geonames:alternateName>
<geonames:alternateName xml:lang='la'>Monacum</geonames:alternateName>
<geonames:alternateName xml:lang='uz'>Munhen</geonames:alternateName>
<geonames:alternateName xml:lang='ca'>Munic</geonames:alternateName>
<geonames:alternateName xml:lang='oc'>Munic</geonames:alternateName>
<geonames:alternateName xml:lang='ast'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='br'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='en'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='eu'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='fr'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='ilo'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='ms'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='nah'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='pam'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='sco'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='tl'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='tum'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='war'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='yo'>Munich</geonames:alternateName>
<geonames:alternateName xml:lang='tet'>Munike</geonames:alternateName>
<geonames:alternateName xml:lang='pt'>Munique</geonames:alternateName>
<geonames:alternateName xml:lang='diq'>Munix</geonames:alternateName>
<geonames:alternateName xml:lang='eo'>Munkeno</geonames:alternateName>
<geonames:alternateName xml:lang='ku'>Munîh</geonames:alternateName>
<geonames:alternateName xml:lang='sq'>Mynihu</geonames:alternateName>
<geonames:alternateName xml:lang='ug'>Myunxén</geonames:alternateName>
<geonames:alternateName xml:lang='scn'>Mònacu</geonames:alternateName>
<geonames:alternateName xml:lang='pms'>Mùnich ëd Baviera</geonames:alternateName>
<geonames:alternateName xml:lang='gl'>Múnic</geonames:alternateName>
<geonames:alternateName xml:lang='an'>Múnich</geonames:alternateName>
<geonames:alternateName xml:lang='es'>Múnich</geonames:alternateName>
<geonames:alternateName xml:lang='ext'>Múnich</geonames:alternateName>
<geonames:alternateName xml:lang='gn'>Múnich</geonames:alternateName>
<geonames:alternateName xml:lang='af'>München</geonames:alternateName>
<geonames:alternateName xml:lang='br'>München</geonames:alternateName>
<geonames:alternateName xml:lang='da'>München</geonames:alternateName>
<geonames:alternateName xml:lang='de'>München</geonames:alternateName>
<geonames:alternateName xml:lang='et'>München</geonames:alternateName>
<geonames:alternateName xml:lang='fi'>München</geonames:alternateName>
<geonames:alternateName xml:lang='hr'>München</geonames:alternateName>
<geonames:alternateName xml:lang='hu'>München</geonames:alternateName>
<geonames:alternateName xml:lang='id'>München</geonames:alternateName>
<geonames:alternateName xml:lang='io'>München</geonames:alternateName>
<geonames:alternateName xml:lang='is'>München</geonames:alternateName>
<geonames:alternateName xml:lang='nds'>München</geonames:alternateName>
<geonames:alternateName xml:lang='nl'>München</geonames:alternateName>
<geonames:alternateName xml:lang='nn'>München</geonames:alternateName>
<geonames:alternateName xml:lang='no'>München</geonames:alternateName>
<geonames:alternateName xml:lang='pdc'>München</geonames:alternateName>
<geonames:alternateName xml:lang='ro'>München</geonames:alternateName>
<geonames:alternateName xml:lang='sl'>München</geonames:alternateName>
<geonames:alternateName xml:lang='sv'>München</geonames:alternateName>
<geonames:alternateName xml:lang='vi'>München</geonames:alternateName>
<geonames:alternateName xml:lang='vo'>München</geonames:alternateName>
<geonames:alternateName xml:lang='lmo'>Münegh</geonames:alternateName>
<geonames:alternateName xml:lang='az'>Münhen</geonames:alternateName>
<geonames:alternateName xml:lang='tr'>Münih</geonames:alternateName>
<geonames:alternateName xml:lang='el'>Μόναχο</geonames:alternateName>
<geonames:alternateName xml:lang='be'>Горад Мюнхен</geonames:alternateName>
<geonames:alternateName xml:lang='mk'>Минхен</geonames:alternateName>
<geonames:alternateName xml:lang='sr'>Минхен</geonames:alternateName>
<geonames:alternateName xml:lang='bg'>Мюнхен</geonames:alternateName>
<geonames:alternateName xml:lang='cv'>Мюнхен</geonames:alternateName>
<geonames:alternateName xml:lang='kk'>Мюнхен</geonames:alternateName>
<geonames:alternateName xml:lang='mhr'>Мюнхен</geonames:alternateName>
<geonames:alternateName xml:lang='mn'>Мюнхен</geonames:alternateName>
<geonames:alternateName xml:lang='os'>Мюнхен</geonames:alternateName>
<geonames:alternateName xml:lang='ru'>Мюнхен</geonames:alternateName>
<geonames:alternateName xml:lang='tg'>Мюнхен</geonames:alternateName>
<geonames:alternateName xml:lang='uk'>Мюнхен</geonames:alternateName>
<geonames:alternateName xml:lang='tt'>Мүнхен</geonames:alternateName>
<geonames:alternateName xml:lang='sah'>Мүнхэн</geonames:alternateName>
<geonames:alternateName xml:lang='mrj'>Мӱнхен</geonames:alternateName>
<geonames:alternateName xml:lang='hy'>Մյունխեն</geonames:alternateName>
<geonames:alternateName xml:lang='he'>מינכן</geonames:alternateName>
<geonames:alternateName xml:lang='yi'>מינכן</geonames:alternateName>
<geonames:alternateName xml:lang='fa'>مونیخ</geonames:alternateName>
<geonames:alternateName xml:lang='ar'>ميونخ</geonames:alternateName>
<geonames:alternateName xml:lang='arz'>ميونيخ</geonames:alternateName>
<geonames:alternateName xml:lang='ckb'>میونخ</geonames:alternateName>
<geonames:alternateName xml:lang='pnb'>میونخ</geonames:alternateName>
<geonames:alternateName xml:lang='ur'>میونخ</geonames:alternateName>
<geonames:alternateName xml:lang='mr'>म्युन्शेन</geonames:alternateName>
<geonames:alternateName xml:lang='hi'>म्यूनिख</geonames:alternateName>
<geonames:alternateName xml:lang='bn'>মিউনিখ</geonames:alternateName>
<geonames:alternateName xml:lang='ta'>மியூனிக்</geonames:alternateName>
<geonames:alternateName xml:lang='kn'>ಮ್ಯೂನಿಕ್</geonames:alternateName>
<geonames:alternateName xml:lang='th'>มิวนิก</geonames:alternateName>
<geonames:alternateName xml:lang='my'>မြူးနစ်ချ်မြို့</geonames:alternateName>
<geonames:alternateName xml:lang='ka'>მიუნხენი</geonames:alternateName>
<geonames:alternateName xml:lang='xmf'>მიუნხენი</geonames:alternateName>
<geonames:alternateName xml:lang='ja'>ミュンヘン</geonames:alternateName>
<geonames:alternateName xml:lang='zh'>慕尼黑</geonames:alternateName>
<geonames:alternateName xml:lang='ko'>뮌헨</geonames:alternateName>
<geonames:countryCode rdf:datatype='http://www.w3.org/2001/XMLSchema#string'>DE</geonames:countryCode>
<geonames:featureClass rdf:resource='http://www.geonames.org/ontology#P'/>
<geonames:featureCode rdf:resource='http://www.geonames.org/ontology#P.PPLA'/>
<geonames:locationMap rdf:resource='http://www.geonames.org/2867714/munich.html'/>
<geonames:name rdf:datatype='http://www.w3.org/2001/XMLSchema#string'>Munich</geonames:name>
<geonames:nearbyFeatures rdf:resource='http://sws.geonames.org/2867714/nearby.rdf'/>
<geonames:parentCountry rdf:resource='http://sws.geonames.org/2921044/'/>
<geonames:population rdf:datatype='http://www.w3.org/2001/XMLSchema#string'>1260391</geonames:population>
<geonames:wikipediaArticle rdf:resource='http://en.wikipedia.org/wiki/Munich'/>
<rdf:type rdf:resource='http://www.geonames.org/ontology#Feature'/>
<rdfs:isDefinedBy rdf:resource='http://sws.geonames.org/2867714/about.rdf'/>
<rdfs:seeAlso rdf:resource='http://dbpedia.org/resource/Munich'/>
<geo:lat rdf:datatype='http://www.w3.org/2001/XMLSchema#string'>48.13743</geo:lat>
<geo:long rdf:datatype='http://www.w3.org/2001/XMLSchema#string'>11.57549</geo:long>
</rdf:Description>
<rdf:Description rdf:about='http://careers.stackoverflow.com/jobs/94342/engineering-systems-data-engineer-arm-ltd'>
<schema:datePosted rdf:datatype='http://www.w3.org/2001/XMLSchema#Date'>2015-09-03T09:43:33+00:00</schema:datePosted>
<schema:datePosted rdf:datatype='http://www.w3.org/2001/XMLSchema#Date'>2015-09-03T09:43:34+00:00</schema:datePosted>
<schema:description rdf:datatype='http://www.w3.org/2001/XMLSchema#string'><p>The Engineering Systems Analytics group is responsible for ensuring that we have a solid understanding of both our engineering infrastructure, which we refer to as the engineering systems stack, and the engineering processes that run on top of it.</p><br /><p>It strives to achieve this goal through a number of parallel activities:</p><br /><ul><br /><li>By helping to refine our spark-based infrastructure that allows relevant data to be centrally collected, aggregated, and processed</li><br /><li>By developing dashboards, reports and complex analysis and/or visualisations of the data that satisfy the business needs, both in terms of project reporting to help measure progress of the work, and in terms of infrastructure reporting to help understand the impact of this work on the estate</li><br /><li>By working with engineering and IT functions to ensure sufficient relevant data is being captured to provide the best information in the above two categories</li><br /></ul><br /><p>We are looking to augment the team with broad additional skills across the areas listed above.</p><br /><p>You will be a software engineer with experience of Spark and R, or equivalents.</p><br /><p>You will be equally at home working on the data processing pipeline, or performing an in depth analysis of the data it contains.</p><br /><p>You will consider yourself a data scientist, keen to tackle the problems of extracting knowledge from data, and driven to understand the core &lsquo;stories&rsquo; that data can tell, and to help drive efficiency and effectiveness improvements by providing the means to make data driven decisions.</p><br /><p>This role be based from ARM's HQ in Cambridge, UK.</p></schema:description>
<schema:hiringOrganization rdf:datatype='http://www.w3.org/2001/XMLSchema#string'>ARM Ltd</schema:hiringOrganization>
<schema:jobLocation rdf:datatype='http://www.w3.org/2001/XMLSchema#string'>Cambridge, UK</schema:jobLocation>
<schema:jobTitle rdf:datatype='http://www.w3.org/2001/XMLSchema#string'>Engineering Systems Data Engineer at ARM Ltd (Cambridge, UK)</schema:jobTitle>
<schema:source rdf:datatype='http://www.w3.org/2001/XMLSchema#string'>StackOverflow</schema:source>
<schema:url rdf:resource='http://careers.stackoverflow.com/jobs/94342/engineering-systems-data-engineer-arm-ltd'/>
<edsa:Location rdf:resource='http://sws.geonames.org/2653941/'/>
<edsa:requiresSkill rdf:resource='http://www.edsa-project.eu/skill/apache-spark'/>
<edsa:requiresSkill rdf:resource='http://www.edsa-project.eu/skill/hadoop'/>
<edsa:requiresSkill rdf:resource='http://www.edsa-project.eu/skill/r'/>
<edsa:requiresSkill rdf:resource='http://www.edsa-project.eu/skill/sql'/>
</rdf:Description>
我是否能够将该函数概括为接受RDF数据并将其输出到类似的样式表中?
我一直在研究rdfstore-js,但我还没能真正开始工作。
答案 0 :(得分:1)
如果您将数据放入RDF数据库并查询它以获取要渲染的数据,我认为您最终会得到更易于维护和扩展的内容。
然后,对于您当前的用例,您可以通过SPARQL协议以CSV或TSV格式询问结果。