Use templates to generate data from your CSV

This conversion is now available as an API at ConvertCsv.io

What can this tool do?

This tool allows you to create output based on a template. You specify what you want to output by using a template for the Header, Repeating Detail, and Footer. The Header is displayed once. The Repeating Detail is displayed once for each record of CSV data. The Footer is displayed once at the end.

What are my options?


  • You can manually create your template.
  • Or let us create your template via the Template Writer.
  • Here are a few of the templates we can create for you:
    • CSV Columns to Rows
    • CSV to C Array
    • CSV to LDIF
    • CSV to HTML Description List - DL/DD/DT tags
    • CSV TO JIRA Table
    • CSV to List (Unordered) - UL/LI tags
    • CSV to LUA Array Table and Dictionary
    • CSV to Python Dictionary
    • CSV to RUBY Language
    • CSV to URL Query String
    • CSV to VbScript Array

What else?



NEW -You can now Save the complete data and settings, and then later Load them from your saved file.
 

Step 1: Select your input



Encoding
 
 

Step 2: Choose input options (optional)


Input Options    Limit # of lines:
Field Separator:



Step 3: Choose output options (optional)





Global Options on each field:
         


Step 4: Use our Sample Templates on Your Data (optional)


Let us write your template for you! Use these below with your data.
Pre-built Templates

Step 5: Create a Template


Enter Template Here
Expert Usage For generating heading and field template below, use {h} for each heading field, and {f} for each field.

Heading :    
Field :    
Regular Usage - use {h1} {h2} ... {f1} {f2} ....








Sort CSV  
 Field #TypeDirection
First By
Then By
Then By

Step 6: Generate Output from Template





Template Help
Note - the Template Engine evaluates text between { and } as Javascript and substitutes the expression value.
ValueDescription
Heading and Fields Variables
{h1} {h2} {h3} ....Heading for field 1,2,3 ...
{H1} {H2} {H3} ....Heading for field 1,2,3 as upper case...
{f1} {f2} {f3} ....Field value 1,2,3 ... or you can use the name of the field in the heading
{F1} {F2} {F3} ....Field value 1,2,3 as upper case...
{fieldname}Alternative to {f1},{f2}... use the field name instead. i.e. {id},{amount}
NOTE - use the FUNCTIONS below, i.e. {name.toJson()} if you need to encode the data
String Constants and Counters
{nf} Number of fields in current row
{nr} Number of data rows in CSV before filtering
{nh} Number of fields in heading row
{rn} Current data row number
{br}Line break
{lb}Left bracket {
{rb}Right bracket }
{seq}Sequence 1,2,3,...
{tab}Tab
Functions
{f1.function()} Where function is a valid Javascript string method or built-in function. Multiple functions are supported via appending to the end
(i.e. f1.trim().toUpperCase()). Partial list of functions below.
{f1.toUpperCase()}Field value to upper case letters
{f1.toLowerCase()}Field value to lower case letters
{f1.toCsv()}convert field to a CSV field by enclosing in double-quotes.
{f1.toDollar()}Format field value as dollar amount
{f1.toFixed(n)}Field value to numeric value with n decimal places
{f1.toHtml()}Make field suitable for viewing as HTML
{f1.toInteger()}Field value to integer value
{f1.toJson()}Make field suitable for JSON value
{f1.toNumber()}Field value to numeric value
{f1.rpad(n)}Right pad field value with spaces until n characters long
{f1.lpad(n)}Left pad field value with spaces until n characters long
{f1.ltrim()}Trim spaces from left side of field
{f1.rtrim()}Trim spaces from right side of field
{f1.rjust(n)}Right justify text to size n. i.e. {f1.rjust(20)}
{f1.ljust(n)}Trim and Left justify text to size n. i.e. {f1.ljust(20)}
{f1.rjust(n)}Trim and Right justify text to size n. i.e. {f1.rjust(20)}
{f1.enclose(ch)}Enclose field by character ch
{f1.cjust(n)}Trim and Center justify text to size n. i.e. {f1.cjust(20)}
{f1.left(n)}Return n characters from left side of field
{f1.right(n)}Return n characters from right side of field
{f1.trim()}Trim spaces from both sides of field
{f1.toSql()}Make field suitable for SQL string value
{f1.toXml()}Make field suitable for viewing as XML
{f1.startsWith(s)}Field starts with string s, i.e. f2.startsWith('Jo'). Returns true or false.
{f1.endsWith(s)}Field end with string s, i.e. f2.endsWith('son'). Returns true or false.