This is an example page showing the desired interpretation of a <csv> element, if added to HTML.
Much of the world's scientific data is stored in CSV files. They can be placed on the web as-is by simply wrapping them in a <pre> element, but that limits their utility as the internal structure is not exposed. This proposal shows how a <pre> might be parsed to expose its internal table structure.
Currently the csv data must conform to a slight superset of RFC 4180; in particular, fields must be surrounded with " (double-quote) if they contain linebreaks or the separator character, and " characters within fields must be represented as "" (two consecutive double-quotes).
This test implementation locates <pre> elements with a data-csv
attribute
and replaces them with an equivalent <table>.
Its behavior can be controled through two attributes.
data-separator
accepts a string that is used to split a row into individual fields.
In this test implementation it must be a valid first argument to the javascript RegExp constructor.
If omitted, it defaults to ",
".
data-header
is a boolean attribute;
if present, it indicates that the first row of the data contains column headings.
Year,Make,Model 1997,Ford,E350 2000,Mercury,Cougar
separator=","
, header
is presentYear,Make,Model 1997,Ford,E350 2000,Mercury,Cougar
separator="\t"
, header
is presentYear Make Model 1997 Ford E350 2000 Mercury Cougar
"Year"FAIL,"""M"" ""ake""",Mo"d""el , , 2000,Mercury,Cougar
"ISSN","Full Title","Change History","Year Range" "00016160","Acta Metallurgica","Continued as Acta Metallurgica et Materialia","1953-1989" "09567151","Acta Metallurgica et Materialia","Formerly known as Acta Metallurgica; Continued as Acta Materialia","1990-1994" "03063747","Additives for Polymers",,"1987-1994" "10657355","Advanced Cement Based Materials","Incorporated into Cement and Concrete Research","1993-1994" "03785963","Applications of Surface Science","Continued as Applied Surface Science","1977-1985" "01691317","Applied Clay Science",,"1985-1994" "09641807","Applied Superconductivity","Title discontinued as of 2000","1993-1994" "01694332","Applied Surface Science","Formerly known as Applications of Surface Science","1985-1994" "01429612","Biomaterials","Incorporating Clinical Materials","1980-1994" "03645916","Calphad",,"1977-1994" "01448617","Carbohydrate Polymers",,"1981-1994" "00086223","Carbon",,"1963-1994" "09589465","Cement and Concrete Composites","Formerly known as International Journal of Cement Composites and Lightweight Concrete","1990-1994" "00088846","Cement and Concrete Research","Incorporating Advanced Cement Based Materials","1971-1994" "02728842","Ceramics International","Formerly known as Ceramurgia International","1981-1994" "03905519","Ceramurgia International","Continued as Ceramics International","1975-1980" "02676605","Clinical Materials","Incorporated into Biomaterials","1986-1994" "01666622","Colloids and Surfaces","Continued as Colloids and Surfaces A: Physicochemical and Engineering Aspects and Colloids and Surfaces B: Biointerfaces","1980-1993" "09277765","Colloids and Surfaces B: Biointerfaces","Formerly part of Colloids and Surfaces","1993-1994" "02638223","Composite Structures",,"1983-1994" "00104361","Composites","Incorporated into Composites Part A: Applied Science and Manufacturing","1969-1994" "09619526","Composites Engineering","Continued as Composites Part B: Engineering","1991-1994" "09567143","Composites Manufacturing","Incorporated into Composites Part A: Applied Science and Manufacturing","1990-1994" "02663538","Composites Science and Technology","Formerly known as Fibre Science and Technology","1985-1994" "09270256","Computational Materials Science",,"1992-1994" "09500618","Construction and Building Materials",,"1987-1994" "0010938X","Corrosion Science",,"1961-1994" "00112275","Cryogenics",,"1960-1994" "01095641","Dental Materials",,"1985-1994" "09259635","Diamond and Related Materials",,"1991-1994" "01437208","Dyes and Pigments",,"1980-1994" "03009416","Electrodeposition and Surface Treatment","Continued as Surface Technology","1972-1975" "00143057","European Polymer Journal",,"1965-1994" "00150568","Fibre Science and Technology","Continued as Composites Science and Technology","1968-1984" "09669795","Intermetallics",,"1993-1994" "01437496","International Journal of Adhesion and Adhesives",,"1980-1994" "02625075","International Journal of Cement Composites and Lightweight Concrete","Continued as Cement and Concrete Composites","1979-1989" "02673762","International Journal of High Technology Ceramics","Continued as Journal of the European Ceramic Society","1985-1988" "01415530","International Journal of Materials in Engineering Applications","Continued as Materials & Design","1978-1979" "02634368","International Journal of Refractory Metals and Hard Materials",,"1991-1994" "00207683","International Journal of Solids and Structures",,"1965-1994" "09258388","Journal of Alloys and Compounds","Formerly known as Journal of the Less Common Metals","1991-1994" "00219797","Journal of Colloid and Interface Science","Formerly known as Journal of Colloid Science","1966-1994" "00958522","Journal of Colloid Science","Continued as Journal of Colloid and Interface Science","1946-1965" "00220248","Journal of Crystal Growth",,"1967-1994" "09552219","Journal of the European Ceramic Society","Formerly known as International Journal of High Technology Ceramics","1989-1994" "00225088","Journal of the Less Common Metals","Continued as Journal of Alloys and Compounds","1959-1991" "00222313","Journal of Luminescence",,"1970-1994" "03048853","Journal of Magnetism and Magnetic Materials",,"1975-1994" "09240136","Journal of Materials Processing Technology","Formerly known as Journal of Mechanical Working Technology","1990-1994" "03783804","Journal of Mechanical Working Technology","Continued as Journal of Materials Processing Technology","1977-1989" "00225096","Journal of the Mechanics and Physics of Solids",,"1952-1994" "00223093","Journal of Non-Crystalline Solids",,"1968-1994" "00223115","Journal of Nuclear Materials",,"1959-1994" "00223697","Journal of Physics and Chemistry of Solids",,"1956-1994" "00224596","Journal of Solid State Chemistry",,"1969-1994" "0022460X","Journal of Sound and Vibration",,"1964-1994" "10445803","Materials Characterization","Formerly known as Metallography","1990-1994" "03906035","Materials Chemistry","Continued as Materials Chemistry and Physics","1976-1982" "02540584","Materials Chemistry and Physics","Formerly known as Materials Chemistry","1983-1994" "02613069","Materials & Design","Formerly known as International Journal of Materials in Engineering Applications","1980-1994" "0167577X","Materials Letters",,"1982-1994" "00255408","Materials Research Bulletin",,"1966-1994" "00255416","Materials Science and Engineering","Continued as Materials Science and Engineering: A and Materials Science and Engineering: B","1966-1988" "09215093","Materials Science and Engineering: A","Formerly part of Materials Science and Engineering","1989-1994" "09215107","Materials Science and Engineering: B","Formerly part of Materials Science and Engineering","1988-1994" "09284931","Materials Science and Engineering: C","Formerly part of Materials Science Reports; Incorporating Supramolecular Science","1993-1994" "0927796X","Materials Science and Engineering: R: Reports","Formerly part of Materials Science Reports","1993-1994" "09202307","Materials Science Reports","Continued as Materials Science and Engineering: C and Materials Science and Engineering: R: Reports","1986-1993" "01676636","Mechanics of Materials",,"1982-1994" "00260657","Metal Powder Report",,"1990-1994" "00260800","Metallography","Continued as Materials Characterization","1968-1989" "01679317","Microelectronic Engineering",,"1983-1994" "00262692","Microelectronics Journal",,"1979-1994" "09276513","Microporous Materials","Incorporated into Microporous and Mesoporous Materials","1993-1994" "09659773","Nanostructured Materials","Incorporated into Acta Materialia and Scripta Materialia","1992-1994" "09253467","Optical Materials",,"1992-1994" "00323861","Polymer","Incorporating Computational and Theoretical Polymer Science","1960-1994" "0883153X","Polymer Contents",,"1987-1994" "01413910","Polymer Degradation and Stability","Incorporating Polymer Photochemistry","1979-1994" "09667822","Polymer Gels and Networks","Title discontinued as of 1999","1993-1994" "01442880","Polymer Photochemistry","Incorporated into Polymer Degradation and Stability","1981-1986" "00323950","Polymer Science U.S.S.R.","Title discontinued as of 1992","1960-1991" "01429418","Polymer Testing",,"1980-1994" "01463535","Progress in Crystal Growth and Characterization","Continued as Progress in Crystal Growth and Characterization of Materials","1977-1990" "09608974","Progress in Crystal Growth and Characterization of Materials","Formerly known as Progress in Crystal Growth and Characterization","1991-1994" "00796425","Progress in Materials Science","Formerly known as Progress in Metal Physics","1961-1994" "05028205","Progress in Metal Physics","Continued as Progress in Materials Science","1949-1959" "03009440","Progress in Organic Coatings",,"1972-1994" "00796700","Progress in Polymer Science",,"1967-1994" "00796786","Progress in Solid State Chemistry",,"1964-1994" "09231137","Reactive Polymers","Formerly known as Reactive Polymers, Ion Exchangers, Sorbents; Continued as Reactive and Functional Polymers","1989-1994" "01676989","Reactive Polymers, Ion Exchangers, Sorbents","Continued as Reactive Polymers","1982-1988" "00343617","Reinforced Plastics",,"1990-1994" "00369748","Scripta Metallurgica","Continued as Scripta Metallurgica et Materialia","1967-1989" "0956716X","Scripta Metallurgica et Materialia","Formerly known as Scripta Metallurgica; Continued as Scripta Materialia","1990-1994" "03796787","Solar Cells","Incorporated into Solar Energy Materials and Solar Cells","1979-1991" "01651633","Solar Energy Materials","Incorporated into Solar Energy Materials and Solar Cells","1979-1991" "09270248","Solar Energy Materials and Solar Cells","Incorporating Solar Cells and Solar Energy Materials","1992-1994" "00381098","Solid State Communications",,"1963-1994" "00381101","Solid-State Electronics",,"1960-1994" "01672738","Solid State Ionics",,"1980-1994" "09262040","Solid State Nuclear Magnetic Resonance",,"1992-1994" "07496036","Superlattices and Microstructures",,"1985-1994" "09685677","Supramolecular Science","Incorporated into Materials Science and Engineering: C","1994" "02578972","Surface and Coatings Technology","Formerly known as Surface Technology","1986-1994" "03764583","Surface Technology","Formerly known as Electrodeposition and Surface Treatment; Continued as Surface and Coatings Technology","1976-1985" "03796779","Synthetic Metals",,"1979-1994" "00406090","Thin Solid Films",,"1967-1994" "00431648","Wear",,"1957-1994" "01442449","Zeolites","Incorporated into Microporous and Mesoporous Materials","1981-1994"