csv2odf(1)
π csv2odf(1) β Text Processing, bestie edition π
okay so first things first: this is the manual page for csv2odf, and it lives in the Text Processing section. Itβs giving βturn my csv chaos into a whole documentβ energy, and honestly? Obsessed. π¦
πΈ NAME πΈ
csv2odf β convert csv files to open document format. periodt.
β¨ SYNTAX β¨
csv2odf [option] [<csvfile>] <templatefile> [<outputfile>]
π DESCRIPTION π
csv2odf is a command line tool that can convert a comma separated value (csv) file into an ods, odt, html, xlsx, or docx document. Itβs lowkey useful for creating reports from databases and other data sources that produce csv files. You can also combine csv2odf with cron and shell scripts to automatically generate business reports β main character automation energy, fr fr. π₯
The csv data is merged with a template file to produce the output file. The template can be a spreadsheet file (ods or xlsx) or a document file (odt or docx), as produced by OpenOffice.org, LibreOffice, or Word. The template can also be an html file. Choices, choices, slay. π
The first row of the table will be treated as a header row. (Override with -H, bestie.) The formatting in the second row of cells will be applied to each data cell of the output file. If the -a option is used, data will be appended below the last existing row, and formatting from the last row will be applied to cells in each new row. Thatβs the vibe. β¨
If the template is a spreadsheet, the second row should contain some data of similar type to the incoming data so that numbers/text/dates can be correctly identified. This is important, donβt skip the vibe check. π«Ά
If the template is a document, it must contain a table that the csv data will be inserted into. If the first table in the file is not the target, use the -t options to identify the table number. Table-hunting, but make it cute. π
If the template is an html file, it must contain a table or div tags that the csv data will be inserted into. If the first table in the file is not the target, use the -t options to identify the table number or table id property. The table may be made using div tags if the --div options is used, in which case a div tag must enclose each cell, each row, and the entire table. Nested divs, but make it fashion. π¦
If a csv input file is not specified, input will be taken from standard input (stdin). If an output file is not specified, output will be directed to standard output (stdout). This allows the use of the command in pipes. Pipes are iconic, no cap. π₯
In the header or footer of the template, you can insert a [csv2odf-date] tag ("csv2odf-date" enclosed in square brackets). The date tag will be replaced by the current date. The date format can be changed using format codes (see below), for example [csv2odf-date %Y-%m-%d] will produce a date like 2008-02-04. A date with a day offset from the current date can be created by using +n or -n, for example [csv2odf-date-1] would insert the date before today. Date math, but make it effortless. β
The options may be placed in the template file. To do this, put "csv2odf:" (without quotes) followed by the options in the first cell (cell A1). Note the first row will be deleted when it contains options. Sneaky little options-in-the-template moment, iykyk. π
π OPTIONS FOR PROCESSING CSV DATA FILE π
-c <char>β use char as delimiter instead of comma.\twill indicate a tab as the dilimiter. (Yes, βdilimiterβ is the word on the page β weβre keeping the lore. π)-o <spec>β specify column order:2,1,3= second csv column will be first column in the output. Also use to leave unchanged the contents of a template column:1,2,,3,4= the 3rd template column is not overwritten. Useful if a column contains a formula. The formula cell references will be offset to the correct row. Formula girlies, this oneβs for you. π-s <n>β start reading at the *n*th row of the csv file.-e <n>β end reading at the *n*th row of the csv file.-d <fmt>β date format within csv data is specified by fmt string, see-Dfor codes. For columns identified as dates, the program will attempt to translate incoming data into the native date coding using the format supplied with the-doption. If the translation fails, it data will be inserted as text. In ods files, the program knows which columns are dates by looking for date formatted cells in the template. In xlsx files you must mark date cells with the text[csv2odf-date](csv2odf-date inside square brackets). Date detective work, but make it spreadsheet. π΅οΈββοΈ-E <encoding>,--csv-encoding=<encoding>β specify the encoding used in the csv file. A list of available encoding names can be found athttps://docs.python.org/3/library/codecs.html#standard-encodings.--default-csv-encodingβ display the default encoding for csv files. This value is system dependent.
π§ OPTIONS FOR PROCESSING TEMPLATE FILE π§
-Hβ insert the first csv row into the header.-S <n>β skip the first n rows of the template file, the header will be the next row after those skipped.-t <n>β specify which tab or table to add data to, default first table. For html files,-tmay be followed by a name to match to table id property.-aβ append csv data to the end of existing data.--comment=<text>β replace[csv2odf-comment]within the document with<text>.--divβ search for<div>tags instead of<table>(html files only).<div>tags must be nested with levels for table, row, and cell.--template-stdin-odsβ The template will be passed to std-in and its format will beods.--template-stdin-odtβ The template will be passed to std-in and its format will beodt.--template-stdin-htmlβ The template will be passed to std-in and its format will behtml.--template-stdin-xlsxβ The template will be passed to std-in and its format will bexlsx.--template-stdin-docxβ The template will be passed to std-in and its format will bedocx.
π GENERAL OPTIONS π
-hβ displays help information.-vβ verbose mode.-Dβ show a list of date format codes (see below).-qβ suppress all warning messages.-xβ create an xml output file instead of odf.-nβ do not merge the data into output, use with-xto extract template xml codes.--input=<file>β specify the csv data file location.--template=<file>β specify the tempate file location. (Typo is canon, bestie. π)--output=<file>β specify the output file location.-Vβ display version number.-zβ display debugging information.
β DATE FORMAT CODES β
The date format codes are the same ones used by Pythonβs strftime function. Cute little strftime codes, coming right up:
%aβ Localeβs abbreviated weekday name.%Aβ Localeβs full weekday name.%bβ Localeβs abbreviated month name.%Bβ Localeβs full month name.%cβ Localeβs appropriate date and time representation.%dβ Day of the month as a decimal number[01-31].%Hβ Hour (24-hour clock) as a decimal number[00-23].%Iβ Hour (12-hour clock) as a decimal number[01-12].%jβ Day of the year as a decimal number[001-366].%mβ Month as a decimal number[01-12].%Mβ Minute as a decimal number[00-59].%pβ Localeβs equivalent of either AM or PM.%Sβ Second as a decimal number[00-61].%Uβ Week number of the year (Sunday as the first day of the week) as a decimal number[00-53]. All days in a new year preceding the first Sunday are considered to be in week 0.%wβ Weekday as a decimal number[0(Sunday)-6].%Wβ Week number of the year (Monday as the first day of the week) as a decimal number[00-53]. All days in a new year preceding the first Monday are considered to be in week 0.%xβ Localeβs appropriate date representation.%Xβ Localeβs appropriate time representation.%yβ Year without century as a decimal number[00-99].%Yβ Year with century as a decimal number.%Zβ Time zone name (no characters if no time zone exists).%%β A literal"%"character.
π EXAMPLES π
Insert data into a spreadsheet:
csv2odf data.csv template.ods output.ods
Insert data into a LibreOffice text document:
csv2odf data.csv template.odt output.odt
Specify format for dates in the csv file:
csv2odf -d "%m/%d/%y %H:%M" data.csv template.ods output.ods
Dates in the csv file can be almost any format. You can tell the program the format to be expected with the -d option. In ods files, the program knows which columns are dates by looking for date formatted cells in the template. In xlsx files, format the date then mark the cell with the text [csv2odf-date] (csv2odf-date inside square brackets). Date formatting, but make it detective work. π΅οΈββοΈ
The csv file has a header on the first row:
csv2odf -H data.csv template.ods output.ods
When the csv file has column names on the first row, -H will cause the column name to be put into the header of the output file. Header glow-up, honestly. β¨
The csv file has a header but we donβt want to use it:
csv2odf -s 2 data.csv template.ods output.ods
This will use data from the csv file beginning with the second row. Skip the header, keep the data, slay. π
okay bestie, thatβs the whole csv2odf(1) manual page β Larry Jordan, July 2014, Text Processing. Periodt. π
π¦ where this page comes from
- nixos 26.05: csv2odf 2.09
- nixpkgs unstable: csv2odf 2.09
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms