You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This command line utility converts [CSV files](http://en.wikipedia.org/wiki/Comma-separated_values) to HTML tables and complete HTML documents. It requires Rust 1.65 or later to build and Python 3.7 or later to test. By default it uses the first row of the CSV file as the [header](https://developer.mozilla.org/en/docs/Web/HTML/Element/th) of the HTML table.
3
+
This command-line utility converts [CSV files](http://en.wikipedia.org/wiki/Comma-separated_values) to HTML tables and complete HTML documents.
4
+
It requires Rust 1.65 or later to build and Python 3.7 or later to test.
5
+
By default, it uses the first row of the CSV file as the [header](https://developer.mozilla.org/en/docs/Web/HTML/Element/th) of the HTML table.
4
6
5
-
The older Python version is preserved in the branch [`python`](https://github.com/dbohdan/csv2html/tree/python).
7
+
The original Python version of csv2html is preserved in the branch [`python`](https://github.com/dbohdan/csv2html/tree/python).
6
8
7
9
8
10
## Installation
9
11
10
-
Prebuilt Linux and Windows binaries are available. They are attached to releases on the [Releases](https://github.com/dbohdan/csv2html/releases) page.
12
+
Prebuilt Linux and Windows binaries are available.
13
+
They are attached to releases on the ["Releases"](https://github.com/dbohdan/csv2html/releases) page.
11
14
12
15
### Installing with Cargo
13
16
@@ -17,32 +20,37 @@ cargo install csv2html
17
20
18
21
### Building on Debian and Ubuntu
19
22
20
-
Follow the instructions to build a static Linux binary of `csv2html` from source on recent Debian and Ubuntu.
23
+
Follow the instructions to build a static Linux binary of csv2html from the source code on recent Debian and Ubuntu.
21
24
22
-
1\. Install [Rustup](https://rustup.rs/). Through Rustup add the stable MUSL target for your CPU.
25
+
1\. Install [Rustup](https://rustup.rs/).
26
+
Through Rustup add the stable musl libc target for your CPU.
3\. Configure Cargo for cross-compilation. Put the following in `~/.cargo/config`.
65
+
3\. Configure Cargo for cross-compilation.
66
+
Add the following in `~/.cargo/config`.
58
67
59
68
```toml
60
69
[target.i686-pc-windows-gnu]
61
70
linker = "/usr/bin/i686-w64-mingw32-gcc"
62
71
```
63
72
64
-
4\. Clone this repository. Build the binary.
65
-
66
-
git clone https://github.com/dbohdan/csv2html
67
-
cd csv2html
68
-
make release-windows
73
+
4\. Clone this repository.
74
+
Build the binary.
69
75
76
+
```
77
+
git clone https://github.com/dbohdan/csv2html
78
+
cd csv2html
79
+
make release-windows
80
+
```
70
81
71
-
## Commandline arguments
82
+
## Command-line arguments
72
83
73
84
```none
74
85
Convert CSV files to HTML tables
@@ -85,38 +96,55 @@ Options:
85
96
-s, --start <N> Skip the first N-1 rows; start at row N
86
97
-r, --renumber Replace the first column with row numbers
87
98
-n, --no-header Do not use the first row of the input as the header
88
-
-c, --complete-document Output a complete HTML document instead of only a table
89
-
--table <ATTRS> HTML attributes for the tag <table> (e.g., --table 'foo="bar" baz' results in the output <table foo="bar" baz>...</table>); it is up to the user to ensure the result is valid HTML
99
+
-c, --complete-document Output a complete HTML document instead of only a
100
+
table
101
+
--table <ATTRS> HTML attributes for the tag <table> (e.g., --table
102
+
'foo="bar" baz' results in the output <table foo="bar" baz>...</table>); it is
103
+
up to the user to ensure the result is valid HTML
90
104
--tr <ATTRS> Attributes for <tr>
91
105
--th <ATTRS> Attributes for <th>
92
106
--td <ATTRS> Attributes for <td>
93
107
-h, --help Print help
94
108
-V, --version Print version
95
109
```
96
110
97
-
98
111
## Use examples
99
112
100
-
The following command reads the data from`test/test.csv` and writes the corresponding HTML table to `test.html`:
113
+
The following command reads the data in`test/test.csv` and writes an HTML table that corresponds to the data to `test.html`:
101
114
102
-
csv2html -o test.html tests/test.csv
115
+
```sh
116
+
csv2html -o test.html tests/test.csv
117
+
```
103
118
104
-
The next command takes semicolon-delimited data from `pub.csv`, starting with row 267. The first column of the table is replaced with the row number starting at 1 (except in the header row, which is untouched). The output is redirected to the file `pub.html`.
119
+
The following command takes semicolon-delimited data from `pub.csv`, starting with row 267.
120
+
The first column of the table is replaced with the row number starting at 1 (except in the header row, which is untouched).
121
+
The output is redirected to the file `pub.html`.
105
122
106
-
csv2html pub.csv -d \; -r -s 267 > pub.html
123
+
```sh
124
+
csv2html pub.csv -d \; -r -s 267 > pub.html
125
+
```
107
126
108
-
Same as above, but this time the output is a full HTML document instead of just the markup for the table:
127
+
The same as above, but the output is a full HTML document instead of just the markup for the table:
109
128
110
-
csv2html pub.csv -d \; -r -s 267 -c > pub.html
129
+
```sh
130
+
csv2html pub.csv -d \; -r -s 267 -c > pub.html
131
+
```
111
132
112
133
If the input file is tab-delimited, use `\t` as the deliminter argument.
113
134
114
-
csv2html --delimiter '\t' tests/test.tsv
135
+
```sh
136
+
# POSIX.
137
+
csv2html --delimiter '\t' tests/test.tsv
138
+
```
115
139
116
-
csv2html-win32.exe --delimiter \t tests/test.tsv
140
+
```batch
141
+
rem Windows.
142
+
csv2html-win32.exe --delimiter \t tests/test.tsv
143
+
```
117
144
118
145
`\t` is the only [backslash escape sequence](https://en.wikipedia.org/wiki/Escape_sequences_in_C) that is implemented.
119
146
120
147
## License
121
148
122
-
Three-clause ("new" or "revised") BSD. See the file `LICENSE`.
0 commit comments