Skip to main content
100%

handle tsv data (ex. delete column)

✓ Published0🌍 Public
HHirosaji
Last edited Jan 25, 2020
Created on Jan 25, 2020

This example demonstrates how to preprocess tab-separated value (TSV) data by removing a column, such as the second field, from a dataset. It reads a TSV file into Python using the `csv.reader` function with a tab delimiter, converts the rows into a list, and then employs NumPy’s `np.delete` function to remove the specified column (index 1). The result is written back to a new TSV file using `csv.writer` with a tab delimiter. The code relies on the standard `csv` module and the NumPy library, with the data sourced from a local file named `test.tsv`.

AI-generated description

Similar vizzes