# CSV to HTML Converter

`csv2html.py` is a Python 3 script that converts a CSV file into HTML
table rows.  It automatically detects the CSV delimiter (comma `,` or
semicolon `;`) and supports optional formatting parameters. It also
escapes HTML reserved characters.

## Usage

Run the script with:
```
python3 csv2html.py --input path_to_csv_file
```

For example:
```
python3 csv2html.py --input data.csv
```

The script will generate an HTML file with the same name as the CSV file,
in this case `data.html`.



## Command Line Options

To see the available options, run:
```
python3 csv2html.py --help
```
or 
```
python3 csv2html.py -h
```

### Compact Output

More compact HTML output (fewer newlines) can be generated
with the --compact option:
```
python3 csv2html.py --compact --input data.csv
```


### Line Wrapping

Text inside table cells can be wrapped at a specified number of characters,
without splitting words with the --wrap option:
```
python3 csv2html.py --wrap --input data.csv
```
By default, lines wrap at most 72 characters. 

A numeric value can be given:
```
python3 csv2html.py --wrap 83 --input data.csv
```
to wrap at a specific number of characters.



### Output File Name
You can also specify the name of output file.

Add this optional flag:
```
python3 csv2html.py --input data.csv --output myfile
```

The output will be saved into myfile.html




### Using All Options

All options can be used together: 
```
python3 csv2html.py --compact --wrap --input data.csv --output myfile
```

## Virtual Environment (Recommended)
Using Python virtual environment is strongly recommended, 
especially because different Python versions can behave differently. 
To guarantee that the script works exactly as expected, it’s recommended to use Python 3.14 inside a virtual environment.
Before you start, make sure you have Python3.14 on your machine.
### 1. Create a virtual environment
```
python3.14 -m venv venv
```

### 2. Activate the virtual environment
#### macOS / Linux:
```
source venv/bin/activate
```
#### Windows:
```
venv\Scripts\activate
```
### 3. Run the script
```
python3 csv2html.py --input data.csv
```
### 4. Deactivate the environment
```
deactivate
```

## Requirements
Python 3.14 version. 

Visit: https://www.python.org/downloads/

No additional libraries or dependencies are required.  The script uses
only Python's standard libraries: `os`, `csv`, `textwrap`,
`argparse`, and `html`.

