Convert RST to TSV
Max file size 100mb.
RST vs TSV Format Comparison
| Aspect | RST (Source Format) | TSV (Target Format) |
|---|---|---|
| Format Overview |
RST
reStructuredText
Lightweight markup language developed by the Python community in 2001. Primary format for Python documentation, Sphinx, and Read the Docs. Emphasizes simplicity and readability with explicit, consistent syntax for technical documentation. Python Standard Sphinx Native |
TSV
Tab-Separated Values
Simple tabular data format where columns are separated by tab characters. Universal format for data exchange between spreadsheets, databases, and data analysis tools. More reliable than CSV for data containing commas. Spreadsheet Data Database Import |
| Technical Specifications |
Structure: Plain text with indentation-based syntax
Encoding: UTF-8 Format: Docutils markup language Processor: Sphinx, Docutils, Pandoc Extensions: .rst, .rest, .txt |
Structure: Rows and columns with tab delimiters
Encoding: UTF-8 (recommended), ASCII Format: Plain text tabular data Processor: Excel, LibreOffice, pandas, databases Extensions: .tsv, .tab, .txt |
| Syntax Examples |
RST table syntax: Data Table ========== +----------+-------+--------+ | Name | Age | City | +==========+=======+========+ | Alice | 28 | London | +----------+-------+--------+ | Bob | 35 | Paris | +----------+-------+--------+ | Charlie | 42 | Tokyo | +----------+-------+--------+ |
TSV syntax (tabs shown as arrows): Name Age City Alice 28 London Bob 35 Paris Charlie 42 Tokyo |
| Content Support |
|
|
| Advantages |
|
|
| Disadvantages |
|
|
| Common Uses |
|
|
| Best For |
|
|
| Version History |
Introduced: 2001 (David Goodger)
Maintained by: Docutils project Status: Stable, actively maintained Primary Tool: Sphinx (2008+) |
Introduced: Early computing era
Standard: IANA media type text/tab-separated-values Status: Universal standard Related: CSV (RFC 4180) |
| Software Support |
Sphinx: Native support
Docutils: Reference implementation Pandoc: Full support IDEs: PyCharm, VS Code (extensions) |
Excel: Full support
LibreOffice: Full support pandas: read_csv(sep='\t') Databases: All major RDBMS |
Why Convert RST to TSV?
Converting reStructuredText (RST) documents to TSV (Tab-Separated Values) format is essential when you need to extract tabular data from documentation for use in spreadsheets, databases, or data analysis tools. RST's table format is great for documentation display, but TSV makes that data accessible to data processing applications.
TSV is often preferred over CSV when your data contains commas, quotes, or other special characters commonly found in text. Since tabs rarely appear in natural text, TSV files are less prone to parsing errors. This makes TSV ideal for extracting text-heavy documentation tables.
The conversion is particularly useful for teams that maintain reference tables in their Sphinx documentation. Configuration options, API parameters, feature comparisons, and specification tables can all be converted to TSV for import into Excel, Google Sheets, or database management tools.
Data analysts frequently need to work with information stored in documentation. By converting RST tables to TSV, you can easily load the data into pandas, R, or other statistical tools for analysis, visualization, or transformation.
Key Benefits of Converting RST to TSV:
- Spreadsheet Import: Open directly in Excel, Google Sheets, LibreOffice
- Database Loading: Bulk import into PostgreSQL, MySQL, SQLite
- Data Analysis: Process with pandas, R, or other tools
- Clean Parsing: Tabs avoid comma/quote escaping issues
- Universal Format: Supported by virtually all data tools
- Compact Size: Minimal overhead compared to structured formats
- Easy Processing: Simple line-by-line and split parsing
Practical Examples
Example 1: Configuration Options Table
Input RST file (config.rst):
Configuration Options ===================== +----------------+----------+-------------------------+ | Option | Default | Description | +================+==========+=========================+ | debug | false | Enable debug mode | +----------------+----------+-------------------------+ | max_retries | 3 | Maximum retry attempts | +----------------+----------+-------------------------+ | timeout | 30 | Request timeout (sec) | +----------------+----------+-------------------------+
Output TSV file (config.tsv):
Option Default Description debug false Enable debug mode max_retries 3 Maximum retry attempts timeout 30 Request timeout (sec)
Example 2: API Reference Table
Input RST file (api.rst):
API Endpoints
=============
+-----------+------------------+----------------+
| Method | Endpoint | Description |
+===========+==================+================+
| GET | /api/users | List users |
+-----------+------------------+----------------+
| POST | /api/users | Create user |
+-----------+------------------+----------------+
| GET | /api/users/{id} | Get user |
+-----------+------------------+----------------+
| DELETE | /api/users/{id} | Delete user |
+-----------+------------------+----------------+
Output TSV file (api.tsv):
Method Endpoint Description
GET /api/users List users
POST /api/users Create user
GET /api/users/{id} Get user
DELETE /api/users/{id} Delete user
Example 3: Feature Comparison
Input RST file (features.rst):
Plan Comparison =============== +-----------+-------+----------+-----------+ | Feature | Free | Pro | Enterprise| +===========+=======+==========+===========+ | Storage | 1GB | 100GB | Unlimited | +-----------+-------+----------+-----------+ | Users | 1 | 10 | Unlimited | +-----------+-------+----------+-----------+ | Support | Email | Priority | Dedicated | +-----------+-------+----------+-----------+ | Price | $0 | $29/mo | Custom | +-----------+-------+----------+-----------+
Output TSV file (features.tsv):
Feature Free Pro Enterprise Storage 1GB 100GB Unlimited Users 1 10 Unlimited Support Email Priority Dedicated Price $0 $29/mo Custom
Frequently Asked Questions (FAQ)
Q: What is TSV format?
A: TSV (Tab-Separated Values) is a simple text format for tabular data where each row is a line and columns are separated by tab characters. It's similar to CSV but uses tabs instead of commas, making it better for text data that may contain commas.
Q: Why use TSV instead of CSV?
A: TSV is preferred when your data contains commas, quotes, or other characters that require escaping in CSV. Since tabs rarely appear in natural text, TSV parsing is simpler and more reliable. Many databases and tools handle TSV more consistently than CSV.
Q: What RST content converts to TSV?
A: Tables in RST (both grid and simple tables) convert to TSV rows and columns. Each table row becomes a TSV line, and table cells become tab-separated values. Non-table content like paragraphs and headers is typically not included in TSV output.
Q: Can I open TSV files in Excel?
A: Yes! Excel fully supports TSV files. You can either open the file directly (Excel will detect the tab delimiter) or use Data > From Text/CSV and specify tab as the delimiter. Google Sheets and LibreOffice Calc also support TSV natively.
Q: How do I load TSV in pandas?
A: Use pandas.read_csv() with the sep parameter: `df = pd.read_csv('file.tsv', sep='\t')`. Alternatively, use `pd.read_table('file.tsv')` which defaults to tab separation. Both methods work equally well for TSV files.
Q: What happens to merged cells in RST tables?
A: TSV doesn't support merged cells. Spanning cells in RST grid tables are typically expanded, with the content appearing in the first cell and subsequent cells left empty. Complex merged structures may need manual adjustment.
Q: How do I import TSV into a database?
A: Most databases support TSV import. In PostgreSQL, use COPY with DELIMITER E'\t'. In MySQL, use LOAD DATA INFILE with FIELDS TERMINATED BY '\t'. SQLite uses .import with .separator '\t'. GUI tools like pgAdmin and DBeaver also support TSV import.
Q: Can I convert TSV back to RST?
A: While not as common, you can convert TSV to RST tables using scripts or tools. Python with the tabulate library can generate RST tables from TSV data. Pandoc also supports conversion from TSV-like formats to RST with proper configuration.